我想点击一个UIButton时添加activityindicator并继续制作动画,直到从服务URL loads.If它加载然后将其移动到下一个view.But我为无法做这样的数据..activityindicator不工作在iPhone的UIButton点击?
这里是我的代码..
-(IBAction)switchtoGetProviders
{
UIActivityIndicatorView *activity = [[UIActivityIndicatorView alloc]initWithFrame:CGRectMake(225, 115, 30, 30)];
[activity setBackgroundColor:[UIColor clearColor]];
[activity setActivityIndicatorViewStyle:UIActivityIndicatorViewStyleGray];
[self.view addSubview:activity];
[activity release];
[activity startAnimating];
NSURL *urlString= [NSString stringWithFormat:@"http://www.something.net/service.svc/Xml"];
if(arr.count>0)
{
[activity stopAnimating];
ViewController2 *gp=[ViewController2 alloc];
[self presentModalViewController:gp animated:NO];
[gp release];
}
else
{
UIAlertView *alert = [[[UIAlertView alloc]initWithTitle: @"Results not found"
message: @""
delegate: self
cancelButtonTitle:@"OK"
otherButtonTitles:nil]autorelease];
[alert show];
}
}
其实这里当ARR为空,我会得到一个alertView
。当alertView
出现然后activityindicator
开始。当我点击确定按钮alertView
然后它停止动画。但我希望它立即开始当UIbutton
被触动..我该怎么做? 我哪里错了?
我做到了,但仍然没有运气 – 07405
请打电话给网络服务或任何你在使用一段时间后使用。我100%确定这个问题是因为计时器。 – Developer