我正在開發一個具有多個viewController的應用程序。第一個是「MainMenu」,第二個是「Page1」。Objective-c:轉到下一頁時「Please wait」消息
我想在下一頁顯示「Please wait ...」的提示。我的代碼如下,但加載「page1」後出現警報。當用戶按下「MainMenu」頁面上的按鈕時,我希望它出現。
你有什麼建議可以實現嗎?
在此先感謝。
AppDelegate.m
-(void)showAlert{
altpleasewait = [[UIAlertView alloc] initWithTitle:@"Please Wait..." message:nil delegate:self cancelButtonTitle:nil otherButtonTitles: nil];
[altpleasewait show];
UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
indicator.center = CGPointMake(altpleasewait.bounds.size.width/2, altpleasewait.bounds.size.height - 50);
[indicator startAnimating];
[altpleasewait addSubview:indicator];
}
-(void)waitASecond{
[self performSelector:@selector(dismissAlert) withObject:self afterDelay:0.8];
}
-(void)dismissAlert{
[altpleasewait dismissWithClickedButtonIndex:0 animated:YES];
}
MainMenu.m
-(void)gotoNextPage{
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication]delegate];
[appDelegate showAlert];
page1 = [self.storyboard instantiateViewControllerWithIdentifier:@"Page1"];
[self presentModalViewController:page1 animated:NO];
}
Page1.m
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication]delegate];
-------------some methods--------------
[appDelegate waitASecond];
你應該嘗試MBProgressHUD:https://github.com/jdg/MBProgressHUD – 2012-03-13 13:59:06
我第二是,完美的作品 – basvk 2012-03-13 14:00:51
哇這很好之一。我會稍後再試。 – user973067 2012-03-13 15:37:18