2012-04-30 12 views
1

私はTableViewControllerで別のビューをプッシュしているカメラビューを持っています。 Navbar Controllerを使用して、メインビューから2番目のビューをプッシュできます。しかし、テーブルビューである第2ビューからの戻るボタンは反応しません。なぜ私は理解できません。UINavigation barのバックボタンが応答しない

ありがとうございます。

@WrightCSご連絡いただきありがとうございます。

私のアプリケーションデリゲートで。

ViewController *vc= [[ViewController alloc] init]; 
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:vc]; 
[self.window setRootViewController :navController]; 
[self.window makeKeyAndVisible]; 
return YES; 

今私は一時的なボタンを使用してビューをプッシュしています。

-(IBAction)testButtonPressed { 
    TableView *tableVC = [[TableView alloc] initWithStyle:UITableViewStylePlain]; 
    [self.navigationController pushViewController:tableVC animated:YES]; 
} 
+0

ビューに使用しているコード、2番目のビューの作成方法など – WrightsCS

+0

@WrightsCS即時応答ありがとうございます。 – ilaunchpad

+0

コード内に、戻るボタンが応答しない理由が示されていません。 – WrightsCS

答えて

0

は、背中のボタンが動作しないことがいくつかの理由があります:カスタムUIButtonやフレームを使用している

  • /境界は、あなたがそれを適切サイズに[yourButtonName sizeToFit] を使用することができます修正されていません。

  • あなたがプログラムではなく、ボタンを追加し、クリックイベントを追加している

    [yourButtonName addTarget:自己アクション:@selector(yourButtonNameTapped :) forControlEvents:UIControlEventTouchUpInside];

イベントを忘れないでください。

... 
-(void)yourButtonNamedTapped:(id)sender 
{ 
... 
} 

ドキュメント:http://developer.apple.com/library/ios/#documentation/uikit/reference/UIControl_Class/Reference/Reference.html

あなたはUINavigationControllerを使用している場合は、[self.navigationController pushViewController:viewControllerName]を使用する場合、バックが自動的に表示されます。

+0

まず、私の質問に答える時間をとってくれてありがとう。私はUINavigationControllerを使用しているので、戻るボタンが付属しています。しかし、私は問題を見つけ出して、それも修正されました。私はあなたのコメントを読んで、私は将来の使用のためにそれの私の心を維持します。それは非常に有益で役立つように見えます。ありがとうございました。 – ilaunchpad

+0

ちょうど好奇心から、何が問題でしたか? –

0
-(IBAction)testButtonPressed { 
     TableView *tableVC = [[TableView alloc] initWithStyle:UITableViewStylePlain]; 

     UIBarButtonItem *backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Back" style:UIBarButtonItemStylePlain target:nil action:nil]; 
     self.navigationItem.backBarButtonItem = backBarButtonItem; 
     [backBarButtonItem release]; 

     [self.navigationController pushViewController:tableVC animated:YES]; 
    } 

私はあなたに役立つと思います。

0
- (void)viewDidLoad 
{  
    UIBarButtonItem *backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Back" style:UIBarButtonItemStylePlain target:self action:@selector(backButtonDidClicked:)]; 
    self.navigationItem.backBarButtonItem = backBarButtonItem; 
    [backBarButtonItem release]; 
} 

-(void)backButtonDidClicked :(id)sender 
{ 
    [self.navigationController popViewControllerAnimated:YES]; 
} 

これはあなたのために働くはずです!

関連する問題