Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 07-29-2010, 07:51 AM   #2 (permalink)
harrytheshark
Registered Member
 
Join Date: Dec 2008
Location: UK
Posts: 1,896
harrytheshark is on a distinguished road
Default

If the processing is a long task done on the main thread, the UIActivityIndicator won't appear. You should do any long tasks on a background thread, then notify the UI of the changes on a background thread.

This is a sample:
Code:
- (void)processPayment:(id)sender {
   PaymentClient * tempPaymentClient = [[PaymentClient alloc] init];
   [self setPaymentClient:tempPaymentClient];
   [tempPaymentClient release];
   
   
   activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
   activityIndicator.frame = CGRectMake(0.0, 0.0, 40.0, 40.0);
   activityIndicator.center = self.view.center;
   [self.view addSubview: activityIndicator];

   [activityIndicator startAnimating];
}
- (void)theProcess {
   NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
   // do the process
   [self performSelectorOnMainThread:@selector(processDone) withObject:nil waitUntilDone:NO];
   [pool release];
}
- (void)processDone {
   [activityIndicator stopAnimating];
   [activityIndicator release];
}
Also, no need for "return;" at the end of a function, because it's returning anyway and if you're not going to use your activityIndicator property, there's no need for it.

Last edited by harrytheshark; 07-29-2010 at 07:54 AM.
harrytheshark is offline   Reply With Quote
 

» Advertisements
» Online Users: 359
13 members and 346 guests
AlanR917, AyClass, blakeart113, Domele, esoteric, ilmman, ipodphone, Kirkout, martianflash, Newbie123, Objective Zero, olivia325, Sesio
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,566
Threads: 94,081
Posts: 402,751
Top Poster: BrianSlick (7,990)
Welcome to our newest member, blakeart113
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 11:11 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.