2014-02-24 44 views
1

大家好我的項目是基於解析json數據並顯示在屏幕上。我已經完成了解析數據和其他所有東西。並在我的項目中使用故事板。現在我的問題是。我有一個任務,我需要驗證加載viewController點擊從tableViewCellif row 6 has been clicked it has to check nsuserdefaults if its null its has ridriect to login page. if login success it has to load a recpective page of row 6。正如上面的屏幕顯示enter image description hereIOS:從uitableview細胞驗證用戶發送ridirect到各自的控制器?

我不能能夠加載登錄屏幕上點擊tableviewcell當我點擊它顯示了這個錯誤:

2014-02-24 10:26:24.775 RT[751:c07] -[RTLoginViewController topViewController]: unrecognized selector sent to instance 0x8dc4510 
2014-02-24 10:26:24.776 RT[751:c07] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[RTLoginViewController topViewController]: unrecognized selector sent to instance 0x8dc4510' 
*** First throw call stack: 
(0x2513012 0x2338e7e 0x259e4bd 0x2502bbc 0x250294e 0x24d9e 0x607285 0x6074ed 0x10115b3 0x24d2376 0x24d1e06 0x24b9a82 0x24b8f44 0x24b8e1b 0x2f937e3 0x2f93668 0x557ffc 0x297d 0x28a5 0x1) 
libc++abi.dylib: terminate called throwing an exception 
(lldb) 

我用這個代碼加載LoginviewController onclicking tableviewcell也正在使用navigationController

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ 
    if(indexPath.section == 0) { 

     if(indexPath.row == 8) { 
      NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; 
      if ([defaults objectForKey:@"firstname"] ==NULL && [defaults objectForKey:@"lastname"]==NULL) { 
      UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone" bundle:nil]; 
      // Get instance of initial Viewcontroller from storyboard 
      UINavigationController *navController = [storyboard instantiateViewControllerWithIdentifier:@"login_id"]; 
      // Get instance of desired viewcontroller 
      RTLoginViewController *viewController = navController.viewControllers[0]; 
      //viewController.kApiKey = apikey; 
      //viewController.kSessionId = sessionid; 
      //viewController.kToken = token; 
      [self presentViewController:navController animated:NO completion:nil]; 

      } 
     } 
} 
} 

請幫我該怎麼辦呢預先感謝

回答

1

這是因爲你在呼喚topViewController方法RTLoginViewController某處,或認爲RTLoginViewController的對象。它在.h或者不存在的地方被錯誤地命名。

編輯1:

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender 
{ 

    if ([[segue identifier] isEqualToString:@"DetailGrandComptes"]) 
    { 
     MyViewController *destination = [segue destinationViewController]; 
     destination.a = 6 ; 
    } 
} 
+0

如何解決,現在這個問題? – Naresh

+0

在您的項目中搜索topViewController ..找到它存在的位置並檢查topViewController中是否有topViewController?使拼寫正確或使其正常... –

相關問題