I am currently building an Iphone app that is using storyboards. I know how to open new views with buttons via the ctrl+click method etc. The problem I have is that when the user clicks the button, I need to do some calculations and processing, as well as opening a web connection to pull data so I can populate the table in the next view but the view opens first before I can do any of this.
What I’m running into is the view is loading long before I am finished connecting to the web service and have calculated and stored the data for the table in the next view, so it loads blank. I need to either call the view in the button programmatically or somehow slow down the processes with some kind of “loading” screen but don’t know how to do either. I guess if its possible to fill the data in the table after the view loads, that could work as well. (if its possible)
Any tips or articles that can point me in the right direction would be appreciated. I haven’t found anything myself.
Thanks.
–connect method–
- (IBAction)connect:(id)sender {
//First begin by logging into the web service.
_email = self.logintxt.text;
// ---SOAP 1.1---
//large soap creation. edited for privacy etc.
NSString *soapMsg =
[NSString stringWithFormat:@"",_logintxt.text
];
//---print it to the Debugger Console for verification---
//NSLog(soapMsg);
NSURL *url = [NSURL URLWithString:
@""];
NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:url];
//---set the headers---
NSString *msgLength = [NSString stringWithFormat:@"%d", [soapMsg length]];
[req addValue:@"" forHTTPHeaderField:@"Host"];
[req addValue:@"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
[req addValue:@"" forHTTPHeaderField:@"SOAPAction"];
[req addValue:msgLength forHTTPHeaderField:@"Content-Length"];
//---set the HTTP method and body---
[req setHTTPMethod:@"POST"];
[req setHTTPBody: [soapMsg dataUsingEncoding:NSUTF8StringEncoding]];
NSURLConnection *conn = [[NSURLConnection alloc] initWithRequest:req delegate:self];
if (conn) {
XMLData = [NSMutableData data];
}
[self performSelector:@selector(getXMLList) withObject:NULL afterDelay:2.0];
[self performSegueWithIdentifier:@"LoginSegue" sender:sender];
what I can suggest is to write the button action yourself. to achieve this you have to put stuff in your .h like
in your .m remember to
then just link the action to your button by using IB, and voila’
the first step is done.
in your .m you can now implement a function MybtnTapped that deals with the data retrival and then opens up the new UIView fulfilled with your new data.