0

私は、START(基本的にログインボタン)とSETTINGSという2つのボタンを備えたnavigationControllerを持つビューを持っています。設定をクリックすると、設定ビューが表示され、計画どおりに終了します。私は設定をクリックし、何もせずに何度も何度もクリックすることができます。良い。iPhone SDK - navController pushViewController - 応答しない

ユーザーがSTARTをクリックすると、SHOWLOGOFFBUTTONSメソッドが呼び出され、navControllerのビューの上部に表示されるボタンが変更されます。 navBarには、LOGOFFボタンのみが必要です。そのボタンをクリックすると、SHOWLOGINBUTTONSが呼び出され、以前と同じログインボタンが表示されるので、ユーザーは設定とSTART(ログイン)に再度アクセスできます。

問題は、「LOGIN」ボタンから「LOGOFF」ボタンへの「ボタンスイッチ」を「LOGIN」ボタンに戻すと、「SETTINGS」ボタンが機能しなくなります。 SHOWSETTINGSメソッドが起動し、実行されます。エラーは発生しませんが、ビューは表示されません。

ご協力いただければ幸いです!

-(void)showLoginButtons{ 
    self.navigationItem.rightBarButtonItem=[[UIBarButtonItem alloc] initWithTitle:@"Settings" style:UIBarButtonItemStylePlain target:self action:@selector(showSettings)]; 
    self.navigationItem.leftBarButtonItem=[[UIBarButtonItem alloc] initWithTitle:@"Start" style:UIBarButtonItemStylePlain target:self action:@selector(tryConnection)]; 
} 

-(void)showLogoffButtons{ 
    self.navigationItem.rightBarButtonItem=nil; 
    self.navigationItem.leftBarButtonItem=[[UIBarButtonItem alloc] initWithTitle:@"Logoff" style:UIBarButtonItemStylePlain target:self action:@selector(resetConnectionAndScreen)]; 
} 

-(void)showSettings{ 
    SettingsViewController *mySettingsViewController= [[SettingsViewController alloc] initWithNibName:@"SettingsViewController" bundle:nil]; 
    iPhone_PNPAppDelegate *mainDelegate = (iPhone_PNPAppDelegate *)[[UIApplication sharedApplication] delegate]; 
    mySettingsViewController.settings=mainDelegate.settings; 
    [[self navigationController] pushViewController:mySettingsViewController animated:YES]; 
    [mySettingsViewController release]; 
} 

答えて

1

ボタンを割り当てる必要があります。ボタンを割り当てる必要があります。このため私は通常、オートリリースを使用します:

-(void)showLoginButtons{ 
    self.navigationItem.rightBarButtonItem=[[[UIBarButtonItem alloc] initWithTitle:@"Settings" style:UIBarButtonItemStylePlain target:self action:@selector(showSettings)] autorelease]; 
    self.navigationItem.leftBarButtonItem=[[[UIBarButtonItem alloc] initWithTitle:@"Start" style:UIBarButtonItemStylePlain target:self action:@selector(tryConnection)] autorelease]; 
} 

showLogoffButtonsメソッドでも同じことをします。

+0

応答のおかげで、Sean - 残念ながら、問題は依然として続きます。 – Dutchie432

+0

問題を修正しましたか?それでも問題が解決しない場合、私はなぜ答えとして選ばれたのだろうと思っていますか? :) – Sean

+0

うーん - それは私がそれがどのように働いているかをチェックする必要がありますのでしばらくありました。私が正しくリコールすれば、問題は2倍になり、正しい方向に私を導きます。ありがとうSean! – Dutchie432

関連する問題