@interface ViewController : UIViewController
{
UIActivityIndicatorView *ActivityView;
}
-(void)ActivityLoad;
-(IBAction)ClickSubmit:(id)sender;
@end
-(void)ActivityLoad
{
ActivityView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
[ActivityView setCenter:CGPointMake(320/2.0, 480/2.0)]; // I do this because I'm in landscape mode
// spinner is not visible until started
[self.view addSubview:ActivityView];
[ActivityView release];
[ActivityView startAnimating];
}
-(IBAction)ClickSubmit:(id)sender
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
[NSThread detachNewThreadSelector:@selector(ActivityLoad) toTarget:self withObject:nil];
//.…
[pool release];[ActivityView stopAnimating];
}
点击按钮使用线程执行UIActivityIndicatorView
最新推荐文章于 2018-02-25 10:48:06 发布