2010-07-19 102 views
0

我用來顯示一個啓動畫面,在後臺從網絡加載一些數據,我也檢查,如果用戶的位置從一個城市改變到另一個城市,我想顯示在警報用戶與你現在在「CityName」中的消息,你想看到這個城市的數據?在啓動畫面上顯示UIAlertView

我有選項卡式應用程序,我已經在應用程序委託類中提供瞭如下的啓動畫面。

SplashViewController *controller = [[SplashViewController alloc] initWithNibName:nil bundle:nil]; 
tabBarController.view.frame = [[UIScreen mainScreen] bounds]; 
controller.tabBarController = self.tabBarController; 
[application setStatusBarStyle:UIStatusBarStyleBlackOpaque]; 
[window addSubview:controller.view ]; 
//[window addSubview:tabBarController.view ]; 

[self.tabBarController presentModalViewController:controller animated:YES]; 
[window makeKeyAndVisible]; 
[controller release]; 

現在,當我顯示警報屏幕會崩潰與「EXC_BAD_ACCESS」消息和堆棧跟蹤顯示,_buttonClick在UIAlertView中類發佈的應用程序。

請告訴我該怎麼做,我也嘗試過使用UIActionSheet,但也有與此相同的問題。

我認爲目前的視圖模型(SplashView)存在一些問題。

在此先感謝。

+0

難道我的策略是錯誤的?我不應該在啓動畫面上識別用戶的位置並從網頁獲取數據? – 2010-07-19 21:26:21

回答

0

我解決這個問題,這個問題是我的飛濺的觀點是建模視圖和

調用[self.tabBarController presentModalViewController:控制器動畫:是];

我做什麼,我轉移了數據下載到另一個視圖控制器有我可以顯示警報,並可以處理

0

你是否試圖在你的SplashViewController viewDidAppear中顯示你的UIAlertView?如果不是,我會先嚐試。我也會確保你的UIAlertView clickedButtonAtIndex方法設置正確,試圖捕獲正在發生的事情。

UIAlertView *alert = [[UIAlertView alloc] 
    initWithTitle:@"Your Location Has Changed" 
    message:@"Your location has changed since you last opened opened THEAPP. Would you like to refresh your data?" delegate:self 
    cancelButtonTitle:@"Cancel" 
    otherButtonTitles:@"OK", nil]; 
alert.tag = 1; 
[alert show]; 
[alert autorelease]; 

那麼對於clickedButtonAtIndex方法:只要你考慮到HIG的使用用戶位置要求

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex { 

    //--NSLog(@"You clicked button #%i",buttonIndex); 

    if (alertView.tag == 1){ 

     if (buttonIndex == 0) { 
      //--NSLog(@"CANCEL"); 

     } else if (buttonIndex == 1) { 
      //--NSLog(@"OK"); 

     } 
    } 
} 

做這一切的啓動畫面上應該罰款。希望這可以幫助!

+0

我仍然收到錯誤!唯一的區別是我做的是釋放警報,你是這樣做autorelease ....重現我認爲你必須打開presentModalViewController視圖,然後顯示警報,在該視圖打開同樣的問題會出現 – 2010-07-20 04:55:43