我正在Xcode 4.2上開發iOS 5.1應用程序。 我有一個uitablcontroller與不同的選項卡。我的問題是當單擊一個選項卡時,應用程序會「凍結」幾秒鐘,並執行所有要執行的代碼,但它不會首先按原樣加載UIAlertView。iOS中的UITab凍結
我有在viewDidLoad中聲明的UIAlertView。 下面的代碼片段:
- (void)viewDidLoad
{
NSLog(@"##### VIEW DID LOAD 1 #####");
// Display Alert: Loading
alertView = [[UIAlertView alloc] initWithTitle:@"Loading"
message:@"\n"
delegate:self
cancelButtonTitle:nil
otherButtonTitles:nil];
UIActivityIndicatorView *spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
spinner.center = CGPointMake(139.5, 75.5); // .5 so it doesn't blur
[alertView addSubview:spinner];
[spinner startAnimating];
[alertView show];
[super viewDidLoad];
NSLog(@"##### VIEW DID LOAD 2 #####");
self.tableView.dataSource = self;
self.tableView.delegate = self;
[self callMainMethod];
}
當單擊該選項卡上,我可以看到第一的NSLog的顯示在登錄,然後主要方法被調用,但不顯示UIAlertView中。
勘誤表,我正在使用Xcode 4.5 – mhmdshawqi
嘗試在自定義實現之前調用superview的'viewDidLoad'。 – Abizern
##解決方案## emrys57的答案解決了問題!答案是將[self callMainMethod]移到viewDidAppear。我還需要在調用函數後根據需要放置[self.tableview reloadData]以查看錶中的數據。 – mhmdshawqi