I need to have a UIButton (with a class of RtnBtn) which basically replicates the back button action used in the navigation bar action at the end of a process - I'm fairly new to IOS dev and I'm not sure how to approach this - should it be done via a push or is there a better option to apply coded action directly to the button?
3 に答える
1
ここにコードを投稿できますか、何をしましたか?、以下のコードでカスタムの戻るボタンを追加できます。
UIButton *buttonBack = [UIButton buttonWithType:UIButtonTypeCustom];
[buttonBack setBackgroundImage:YOURImage forState:UIControlStateNormal];
[buttonBack addTarget:self action:@selector(backPressed) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *backButton = [[[UIBarButtonItem alloc] initWithCustomView:buttonBack] autorelease];
self.navigationItem.leftBarButtonItem = backButton;
イベントを処理するメソッド、
-(void)backPressed
{
[self.navigationController popViewControllerAnimated:YES];
}
于 2013-10-24T11:07:18.483 に答える
1
ボタンを作成し、そのアクションとしてセレクターを指定し、そのメソッドpopViewController:animated:
でナビゲーション コントローラーを呼び出す必要があります。
于 2013-10-24T11:08:26.200 に答える