Xcode4.2でiOS5.1アプリケーションを開発しています。さまざまなタブを持つuitablcontrollerがあります。私の問題は、タブがクリックされると、アプリケーションが数秒間「フリーズ」し、本来のコードをすべて実行しますが、UIAlertViewが最初に読み込まれないことです。
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がログに表示され、次にmainメソッドが呼び出されたことがわかりますが、UIAlertviewは表示されません。