簡體   English   中英

iPhone SDK:pushViewController崩潰

[英]iPhone SDK: pushViewController crashing

我在使用pushViewController加載詳細視圖時遇到問題。 起初,我認為pushViewController無法正常工作。 但是,然后我嘗試使用其他視圖控制器,它起作用了。 從跟蹤中可以看出,問題視圖控制器從未加載過。 換句話說,我試圖通過NSLoging消除該對象在視圖控制器中出現錯誤的可能性,而我從沒看到任何東西。

有人有什么想法嗎?

- (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]; 


}

只需檢查

- (void)viewWillAppear:(BOOL)animated
{


}

salesViewController

您在這方面做錯了..

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

在我的情況下,我有幾個IBOutlet已從Header文件中刪除,卻忘記了刪除與Interface Builder中這些不存在的插座的連接。 因此,就我而言,刪除過時的插座可以解決此問題。

當您從ViewController1推送到ViewController2時,該代碼將像這樣使用,因此請嘗試以下代碼,

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

上面的代碼可以寫在按鈕的Click事件上或UITableView的didSelect委托上

只需嘗試...肯定會為您工作...

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。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM