UIActivityIndicator
このリンク(http://www.cocoacontrols.com/platforms/ios/controls/mbprogresshud)を参照して使用しようとしていますが、ここに問題があります。同じ状態を維持したまま数秒間インジケーターを表示する必要がViewController
あります。その後、ナビゲートする必要がありますが、ボタンをクリックしたときのようにコードがナビゲートしてインジケーターを表示するだけです。インジケータープロセスが完了するまで、数秒間ナビゲートを停止できますか?
- (void)myProgressTask {
// This just increases the progress indicator in a loop
float progress = 0.0f;
while (progress < 1.0f) {
progress += 0.01f;
HUD.progress = progress;
usleep(50000);
}
}
-(IBAction)loginActionforIphone:(id)sender
{
HUD = [[MBProgressHUD alloc] initWithView:self.navigationController.view];
[self.navigationController.view addSubview:HUD];
// Set the hud to display with a color
HUD.color = [UIColor colorWithRed:0.23 green:0.50 blue:0.82 alpha:0.90];
HUD.delegate = self;
[HUD showWhileExecuting:@selector(myProgressTask) onTarget:self withObject:nil animated:YES];
if([loginText_ipad.text length]<=0||[passwordText_ipad.text length]<=0)
{
UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"" message:@"Please enter all the fields" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
[alert show];
[alert release];
}
else
{
if(([loginText_ipad.text isEqualToString:@"21770765"]&&[passwordText_ipad.text isEqualToString:@"21770765"])||([loginText_ipad.text isEqualToString:@"21770766"]&&[passwordText_ipad.text isEqualToString:@"21770766"]))
{
HPEBDashboardViewController_iphone *dashboardView = [[HPEBDashboardViewController_iphone alloc] initWithNibName:@"HPEBDashboardViewController_iphone" bundle:nil];
if([loginText_ipad.text isEqualToString:@"21770765"])
{
dashboardView.buttonvalue=1;
}
else
{
dashboardView.buttonvalue=2;
}
[self.navigationController pushViewController:dashboardView animated:YES];
}
else
{
UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"" message:@"Invalid credentials" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
[alert show];
[alert release];
}
}
}