2011-01-25 26 views
2

選中此項,即時推送另一個模態視圖內的模態視圖。但是,即時通訊試圖在此模式視圖內放置一個按鈕,但沒有運氣。將一個後退按鈕置於模態視圖中被另一個模態視圖推送

什麼即時做錯了?

謝謝!

CadastroViewController *addController = [[CadastroViewController alloc] initWithNibName:@"CadastroViewController" bundle:nil]; 

// This is where you wrap the view up nicely in a navigation controller 
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:addController]; 

// You can even set the style of stuff before you show it 
navigationController.navigationBar.barStyle = UIBarStyleBlackOpaque; 

navigationController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"OK" style:UIBarButtonItemStyleBordered target:self action:@selector(buy)]; 


// And now you want to present the view in a modal fashion all nice and animated 
[self presentModalViewController:navigationController animated:YES]; 

// make sure you release your stuff 
[navigationController release]; 
[addController release]; 
+0

我找到了答案。謝謝。 – 2011-01-25 17:14:21

+1

請與我們其他人分享您的答案。 – 2011-02-22 13:53:58

回答

0

在我看來,這個問題是在這裏:

[self presentModalViewController: navigationController animated:YES]; 

而是嘗試做到這一點:

[self presentModalViewController: addController animated:YES]; 
1

你應該在 ​​您CadastroViewController控制器的添加按鈕

這看起來像這樣:

- (void) viewDidLoad 
{ 
    [super viewDidLoad]; 
    UIBarButtonItem *button = [[UIBarButtonItem alloc] initWithTitle:@"OK" style:UIBarButtonItemStyleBordered target:self action:@selector(buy)]; 
    self.navigationController. leftBarButtonItem = button; 
    [button release]; 
} 

[self presentModalViewController: navigationController animated:YES];是確定你的榜樣,就像所有其他的初始化,你應該在viewDidLoad中

2

做您將有一個新的UINavigationItem添加到實際視圖 - 控制的導航欄 - 而不是導航控制器。

addController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"OK" style:UIBarButtonItemStyleBordered target:self action:@selector(buy)]; 
相關問題