我有以下代碼:IOS:UIAlertView中立即顯示之前,循環執行
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Loading Content For the First Time..."
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];
for (TCMLevelRemote *level in [obj objectForKey:@"levels"]){
[[TCMExhibitFeedStore sharedStore] createLevel:level];
}
[[TCMExhibitFeedStore sharedStore] loadAllLevels];
[[TCMExhibitFeedStore sharedStore] setAllLevels:[[TCMExhibitFeedStore sharedStore] storedLevels]];
[alertView dismissWithClickedButtonIndex:0 animated:YES];
的for循環需要一段時間才能執行,因爲它爲下載第一次應用程序運行的一些信息。所以我想要顯示這個通知,以便用戶不會坐在無反應的屏幕上等待。問題是在for循環結束之前alertview不顯示。然後它就馬上消失。我需要改變什麼?
對於CGD這是最好的選擇,你可以忽略/刪除'performSelector' :)) – danypata
是的,你是對的CGD是我們最好的...... :) –