2011-01-26 1 views
2

これは私の最初の投稿ですので、優しくしてください。rootViewControllerのマルチレベルナビからdetailViewController.detailItemを更新するには

xcode内で基本的な分割ビューベースのアプリケーションを使用していますが、rootViewControllerが単にdetailViewControllerを更新するのではなく、新しいUITableViewController(taskViewController)をナビゲーションスタックにプッシュするように編集しました。

私の問題は、私は今、私のtaskViewControllerから以下を呼び出したときに何も起こらないことを、次のとおりです。

detailViewController.detailItem = [NSString stringWithFormat:@"Row %d", indexPath.row]; 

私が代わりにスタックに新しいのUITableViewを押す、それは動作しますが、rootViewControllerからこれを呼び出した場合。セルが選択されたときにここで

はrootViewControllerから私のコードです:

- (void)tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    TaskViewController *taskViewController = [[TaskViewController alloc] init]; 

    taskViewController.title = [NSString stringWithFormat:@"Unit %d",indexPath.row]; 

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

    [taskViewController release]; 
} 

は、私はここで何か間違ったことをしたのでしょうか。 UISplitViewControllerのrootViewController内でナビゲーションコントローラを正しく使用していますか?

答えて

5

あなたのrootViewControllerはreferViewを持っているのでdetailViewControllerにアクセスできます。新しいコントローラをnavスタックにプッシュすると、でなく、が自動的にDetailViewControllerについて知ります。

あなたのタスクVCにNSLogのd detailViewControllerがありますか?

- (void)tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
    { 
     TaskViewController *taskViewController = [[TaskViewController alloc] init]; 

     taskViewController.title = [NSString stringWithFormat:@"Unit %d",indexPath.row]; 

     taskViewController.detailViewController = self.detailViewController; 

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

     [taskViewController release]; 
    } 
+0

ファンタスティック:あなたはこのようにそれを作成しているとき

通常はこれを設定します!私はちょうどUISplitViewControllerがこのすべてを世話したと仮定しました。ありがとう – Peetz

+0

それは基本的なルートとディテールVCの限りではありましたが、それ以降は自分のdwで、あなたの出発時によくある間違いです。 SplitViewControllerには他の問題もありますが、私はあなた自身でその旅を取ることができます。 「NSLog」はあなたの友人です。 –

関連する問題