簡體   English   中英

將視圖推送到第二個導航控制器

[英]Pushing view to second Navigation Controller

我有一個包含兩個項目的標簽欄應用程序。 這兩個不同的標簽欄項包含2個不同的導航控制器。 第一個導航控制器工作正常,但是當我想將視圖推送到第二個導航時,它會生成“應用程序試圖將零個視圖控制器推送到目標”。

這是我將視圖推送到第二個導航控制器的代碼。

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

TabNavAppDelegate *appDelegate = (TabNavAppDelegate *)[[UIApplication sharedApplication] delegate];
JJ_MapAnnotation *anno = (JJ_MapAnnotation *) [depotsArray objectAtIndex:indexPath.row];
if(self.secondViewController ==nil)
{
    SecondViewController *secView = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];
    self.secondViewController == secView;
    [self.secondViewController.map addAnnotation:anno];
    [secView release];
}


secondViewController.title = [NSString stringWithFormat:@"%@", [anno title]];

[appDelegate.navController pushViewController:secondViewController animated:YES]; 

我敢打賭:

if(self.secondViewController ==nil)

self.secondViewController不是nil也不是有效的對象。 可能那里有一些垃圾。 當您執行這種動態分配時,請確保您的對象在釋放后變為零。 否則,您可能會遇到類似這種情況。 希望對您有所幫助

更新:

==運算符在這里不正確;)

self.secondViewController == secView; //WRONG
self.secondViewController = secView; //OK

暫無
暫無

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

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