views:

1931

answers:

2

i have a tableview controller, when i select a row its pushing another view controller. In that view controller 's loadView i have to request a url. it will take 5 or 10 secs to complete the request. i have to show UIActivityIndicatorView for that delay . I have a UIActivityIndicatorView in my table view didSelectRowAtIndexPath and I'd like to "start" and "stop" animation. But it is not starting the animation before it pushing the view controller. so that its not visible when the delay hapnd. i cant use uiwebview due to some reasons.

+1  A: 

[activityindicator startAnimating]; timer=[NSTimer scheduledTimerWithTimeInterval:0 target:self selector:@selector(CallThread) userInfo:nil repeats:YES];

-(void)CallThread { //do your url request process

[activityindicator stopAnimating];

}

A: 

Try posting the code in your didSelectRowAtIndexPath. You're probably downloading the url synchronously, which is causing your delay. Try using the asynchronous methods of NSUrlConnection: http://developer.apple.com/documentation/Cocoa/Conceptual/URLLoadingSystem/Tasks/UsingNSURLConnection.html#//apple_ref/doc/uid/20001836-BAJEAIEE

Dan Lorenc