我要開始按鈕的動作示忙,我用IB行動,下面的代碼:如何在iOS上的按鈕操作上顯示繁忙的指示燈?
busyIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
busyIndicator.center = self.view.center;
[busyIndicator setColor:[UIColor redColor]];
[self.btnInjuryPrevention addSubview:busyIndicator];
[self.view addSubview:busyIndicator]; // spinner is not visible until started
[busyIndicator startAnimating];
if(![AppStatus isAppOnline]) {
noInternetViewController = [[NoInternetViewController alloc] initWithNibName:@"NoInternetViewController" bundle:[NSBundle mainBundle]];
noInternetViewController.view.tag = CHILD_CONTROLLER_TAG;
[self.navigationController pushViewController:noInternetViewController animated:YES];
NSLog(@"Yoy are offline..>!!");
}
else
{
mInjuryPreventionViewController=[[InjuryPreventionViewController alloc] initWithNibName:@"InjuryPreventionViewController" bundle:nil withHeader:@" Injury Prevention" withId:INJURY_PREVENTION_ID];
mInjuryPreventionViewController.view.tag = CHILD_CONTROLLER_TAG;
[self.navigationController pushViewController:mInjuryPreventionViewController animated:YES];
//[mInjuryPreventionViewController release];
}
// [self removeLoadingView];
[busyIndicator stopAnimating];
我上面的代碼中使用,但忙碌的指示燈將無法啓動,所以,你可以告訴我這是可能的嗎?
請顯示整個方法。該方法是否在'[busyIndicator startAnimating]之後立即結束;'? – dasblinkenlight 2012-07-25 10:20:50
嘗試'UIActivityIndicatorViewStyleGray',你可能看不到指示器,因爲我相信它已經在iOS 4中失去了陰影。 – 2012-07-25 10:23:15
確保你設置了活動指示器的框架 - 我相信初始化框架等於CGRectZero。 – 2012-07-25 10:30:06