按钮上的活动指示器单击 [英] activity indicator on button click
本文介绍了按钮上的活动指示器单击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在制作一个iPhone应用程序,在其中一种视图中,我试图将活动指示器放在按钮单击上.每当用户单击按钮时,指示器必须启动,并且在该按钮结束时,指示器必须停止.我已经尝试实现它.但是它不能正常工作.如果有人有解决方案.请告诉我.
I am making an iphone app, in one of the view I am trying to put the activity indicator on button click. Whenever user clicks on button, indicator must starts and at the end of this button activity indicator must stop. I have tried to implement it. But it is not working properly. If someone has the solution for it. Please let me know.
-(void)temp
{
spinner = [[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
spinner.frame = CGRectMake(0.0, 0.0, 40.0, 40.0);
[spinner setCenter:CGPointMake(480/2.0, 128.0/2)]; // (mid of screen) I do this because I'm in landscape mode
[timetable addSubview:spinner];
[spinner startAnimating];
[spinner release];
}
-(IBAction)datetimeis:(id)sender
{
[self temp];
for (int d=0 ; d<=[totaltimearray count]-1; d++)
{
for (int e=0 ; e<=[appendarray count]-1; e++)
{
appenddate = [appendarray objectAtIndex:e];
datestring = [NSString stringWithFormat:@"%@",appenddate];
appendtime = [totaltimearray objectAtIndex:d];
timestring = [NSString stringWithFormat:@"%@",appendtime];
rslttwostr = [datestring stringByAppendingFormat:@"%@",timestring];
NSLog(@"timestring is:%@",rslttwostr);
[dateandtime addObject:rslttwostr];
NSLog(@"dateandtimeis:%@",dateandtime);
}
}
totaltimewithdate = dateandtime;
[self savedetails];
[self docmedname];
[self retrivenotificationarray];
//[barButton release];
[self.navigationController popToRootViewControllerAnimated:YES];
}
非常感谢.
推荐答案
将此行放在按钮操作开始时...
Place this line at start of button action...
[NSThread detachNewThreadSelector:@selector(StartActivityIndicator) toTarget:self withObject:nil];
添加此方法...
-(void)StartActivityIndicator
{
[activityIndicator startAnimating];
}
这篇关于按钮上的活动指示器单击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文