2010-09-17 90 views
0

我有問題獲取使用pushViewController加載的詳細視圖。起初,我認爲pushViewController沒有工作。但是,然後我嘗試使用不同的視圖控制器,它工作。我可以從跟蹤中得知,問題視圖控制器從來沒有加載過。換句話說,我試圖通過NSLoging消除在視圖控制器中出現錯誤的可能性,並且我從來沒有看到任何東西。iPhone SDK:pushViewController崩潰

有沒有人有任何想法?

- (void)tableView:(UITableView *)tableView 
didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 

/* 
    NSLog(@"hsitkjsdfkljlkd"); 

    if (childController == nil) 
     childController = [[salesViewController alloc] initWithNibName:@"salesView" bundle:nil]; 

    //NSUInteger row = [indexPath row]; 

    [self.navigationController pushViewController:childController 
             animated:YES]; 

*/ 

/* 

    //modal = blocking 
    salesViewController *otherVC = [[salesViewController alloc] initWithNibName:@"salesView" bundle:nil]; 

    //must set sale type 
    otherVC.strSaleType = @"Voice"; 

    [self presentModalViewController: otherVC animated:YES]; 

    //No close. By design, it is up to the otherVC to close itself 

    */ 

    //tipCalcViewController *detailViewController = [[tipCalcViewController alloc] initWithNibName:@"tipCalcView" bundle:nil]; 
    salesViewController *detailViewController = [[salesViewController alloc] initWithNibName:@"salesView" bundle:nil]; 
    // ... 
    // Pass the selected object to the new view controller. 

    [self.navigationController pushViewController:detailViewController animated:YES]; 
    [detailViewController release]; 


} 
+0

您是否在控制檯崩潰時看到任何錯誤消息? – Vladimir 2010-09-17 16:04:01

+0

以上,加上,你確定你指定的筆尖名稱是正確的? – 2010-09-17 16:10:04

+0

沒有控制檯消息。筆尖的名字也是正確的。如何解決問題? – butchcowboy 2010-09-17 17:47:16

回答

0

只是嘗試一下......當然,它會爲ü工作...

salesViewController *detailViewController = [[salesViewController alloc] initWithNibName:@"salesViewController" bundle:nil]; 

// Pass the selected object to the new view controller. 

[self.navigationController pushViewController:detailViewController animated:YES]; 
[detailViewController release]; 

另外,還要確保你給的IBOutlet中連接的UIView。

3

只是檢查

- (void)viewWillAppear:(BOOL)animated 
{ 


} 
salesViewController

你正在做的事情錯在這..

把調試點在viewWillAppear並運行它。你可以得到錯誤行..

0

在我的情況下,我有幾個IBOutlets,我從頭文件中刪除,忘記刪除連接到這些不存在的接口在Interface Builder中。因此,刪除過時的網點解決了我的問題。

0

當你從ViewController1推到ViewController2則將使用這樣的代碼,所以試試這個代碼,

ViewController2 *vw2=[[ViewController2 alloc]initWithNibName:@"ViewController2" bundle:nil]; 
[self.navigationController pushViewController:vw2 animated:YES]; 

上面的代碼可以在按鈕或didSelect Click事件被寫入UITableView的代表