如何將動作設置爲導航欄上的backButtonItem?我有一個導航欄,當我按下後退按鈕時,我需要向用戶發送一條消息,並且只有在用戶的反應後才返回到前一個視圖。我該怎麼做?感謝名單!如何將動作設置爲導航欄上的backButtonItem?
- (void)viewDidLoad
{
[super viewDidLoad];
//no one field don't changed yet
isDirty = FALSE;
//edited user
//set default values
newData = [data copy];
//setting navigation controller rigth button
UIBarButtonItem *rightButton = [[UIBarButtonItem alloc] initWithTitle:@"Save"
style:UIBarButtonSystemItemDone
target: self
action: @selector(saveBtnUserClick)];
self.navigationItem.rightBarButtonItem = rightButton;
[rightButton release];
UIBarButtonItem *leftButton = [[UIBarButtonItem alloc] initWithTitle:@"Back"
style:UIBarButtonSystemItemDone
target: self
action: @selector(backBtnUserClick)];
self.navigationItem.backBarButtonItem = leftButton;
[leftButton release];
}
//我的反應
-(IBAction) backBtnUserClick
{
NSLog(@"\n Back pressed");
//back to previous view
[self.navigationController popViewControllerAnimated: TRUE];
}
感謝名單用這個!但!!如何設置導航控制返回按鈕的方法。我做不到。 – yozhik 2010-11-18 01:00:44
看到我上面的編輯。 – 2010-11-18 15:14:10