See following code for this:
// new transparent view to disable user interaction during uploading.
UIView *loadView = [[UIView alloc] initWithFrame: [[UIScreen mainScreen] bounds]];
//Loader spinner
UIActivityIndicatorView *act = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
[loadView addSubview:act];
act.center =loadView.center;
[self.view addSubview:loadView];
[self.view bringSubviewToFront:loadView];
[act startAnimating];
[act release];
[loadView release];
[NSThread detachNewThreadSelector:@selector(doWork) toTarget:self withObject:nil];
Here is doWork method which contains all time consuming task. It is executed in separate thread so you can’t access UI elements in this method.- (void) doWork {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
.....Time Consuming Code here .....
[pool release];
}
Hope, It helps.
No comments:
Post a Comment