pushViewControllerとtableViewControllerにviewController
質問
いUIViewController、このコントローラが含まれまnavigationController.私は追加UITableViewControllerこのviewController.う呼pushViewController法の時に押し、細胞のtableView.
やってみると:
UITableViewController
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
FirstView *myViewController = [[FirstView alloc] init];
[f myViewController];
}
UIViewController(FirstView)
-(void)pushIt
{
SecondView *sCont = [[SecondView alloc] initWithNibName:@"SecondView" bundle:[NSBundle mainBundle]];
[self.navigationController pushViewController:sCont animated:YES];
NSLog(@"didSelect"); // is printed
[sCont release];
sCont = nil;
}
でも何も起きない。いNSLog()は私のpushIt方法及びこれを訳していただけませんか?.いかわからないのはなぜできない押します。
ずっと面白いアイデアないか?
解決
UIViewController
は、次の名前のプロパティ navigationController
ることがあります。 UINavigationController
存在する場のリスナーをアンインストールコントローラー社と呼ばれます。
この性質を利用できるプビューのコントローラへの航スタックからのテーブルビューの didSelectRowAtIndexPath:
方法。
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
SecondView *sCont = [[SecondView alloc] initWithNibName:@"SecondView" bundle:[NSBundle mainBundle]];
[self.navigationController pushViewController:sCont animated:YES];
[sCont release];
}
その理由現在のコードな作業であるかのように
- だき,誠にありがとうございインスタンスのFirstViewController,っているということを追加するテーブルビューとしてsubview
- だそうとして新しいインスタンスを作成し、FirstViewController、ユーザがタップ細胞ではないが、ナスタック、そしようと押しviewコントローラーのスタックが動作しないので、
navigationController
性を返します無料。
他のヒント
あなたはのallocとinit myViewControllerが、その後、あなたがmyViewControllerにSCONTを押し、ナビゲーションやウィンドウまたは任意の他にそれをプッシュすることはありません、それは窓に存在しません。まず、myViewControllerを使用しないようにしよう、次のことにSCONTをプッシュする前に、ナビゲーションにmyViewControllerをプッシュしよう。
所属していません StackOverflow