1

私のアプリケーションは、モーダルpushViewControllerとpopToRootViewController

[navigationController pushViewController:_viewController animated:YES]; 

行わボタンが、私はそれが戻ってメインにナビゲートする必要があることを望ん押すと、ナビゲーションコントローラはボタン

UIButton* backButton = [UIButton buttonWithType:101]; 
[backButton addTarget:self action:@selector(dismissView:) forControlEvents:UIControlEventTouchUpInside]; 
[backButton setTitle:@"Done" forState:UIControlStateNormal]; 

UIBarButtonItem* backItem = [[UIBarButtonItem alloc] initWithCustomView:backButton]; 

self.navigationItem.leftBarButtonItem = backItem; 
[backItem release]; 

を行っているナビゲーションコントローラを表示するにはpushViewControllerを使用していますウィンドウ

-(void) dismissView: (id)sender 

{ 
    [self.navigationController popToRootViewControllerAnimated:YES]; 
//[self.navigationController popToViewController:_viewController animated:YES]; 

} 

しかし、私が完了ボタンを押すと何も起こりません。何故ですか?かなり確実

+0

完了ボタンを初期化するコードはどこに置いていますか? "dismissView:"セレクタの中にNSLogステートメントを追加して、実際に呼び出されているかどうかを確認しましたか? – nickbona

+0

完了ボタンをどのように初期化できますか? – user1120133

答えて

1

NSにログインしてくださいdismissView

-(void) dismissView: (id)sender 

{ 
    NSLog(@"Hii...."); 
    [self.navigationController popToRootViewControllerAnimated:YES]; 
//[self.navigationController popToViewController:_viewController animated:YES]; 

} 

または、ブレークポイントでアプリをデバッグします。

1
UIButton* backButton = [UIButton buttonWithType:101]; 

イム "101" は、以下のUIButtonTypeは、あなたのコードは、あなたのdismissViewにいくつかのNSLogを入れて、そのテスト以外の

typedef enum { 
    UIButtonTypeCustom = 0, 
    UIButtonTypeRoundedRect, 
    UIButtonTypeDetailDisclosure, 
    UIButtonTypeInfoLight, 
    UIButtonTypeInfoDark, 
    UIButtonTypeContactAdd, 
} UIButtonType; 

値のいずれかを使用する必要があり、無効

+ (id)buttonWithType:(UIButtonType)buttonType 

です:呼び出されるかどうかを確認する

関連する問題