1

我需要實現後退按鈕; (如在網頁中,當您點擊back按鈕時,屏幕會將焦點設置到之前的屏幕)。iPhone導航按鈕上一個按鈕 - 初學者

我在這裏沒有使用導航控件,而是我想用Navigation bar然後在其上添加navigation button來做到這一點。現在當用戶點擊navigation button時,應該顯示先前的view

我應該怎麼做。

我的屏幕看起來是這樣的:

當我對你好點擊,就應該去上一個屏幕。 enter image description here

回答

2

退房UINavigationController Class Regerence然後嘗試這樣的事:

- (void)pickerCancel { 
    [self dismissModalViewControllerAnimated:YES]; 
} 

- (void)doSomething { 
    [myView.navigationItem setBackBarButtonItem:[[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(pickerCancel)] autorelease]]; 
    UINavigationController *navigation = [[UINavigationController alloc] initWithRootViewController:myView]; 
    [navigation setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal]; 
    [navigation setDelegate:self]; 
    [self presentModalViewController:navigation animated:YES]; 
    [myView release]; 
    [navigation release]; 
}