开发者

Right button not appearing on modal view controller

开发者 https://www.devze.com 2023-03-27 15:17 出处:网络
I\'m trying to add a button to a modal view controller so it 开发者_C百科can be dismised but the button is not displaying. Any help would be appreciated.

I'm trying to add a button to a modal view controller so it 开发者_C百科can be dismised but the button is not displaying. Any help would be appreciated.

Here is the code:

UIViewController* webView = [[UIViewController alloc] init];

UINavigationController* modalViewController = [[UINavigationController alloc]  initWithRootViewController:webView];
[webView release];

UIBarButtonItem *doneButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(hideModalView)];
modalViewController.navigationItem.rightBarButtonItem = doneButton;
[doneButton release];

[globalNavController presentModalViewController:modalViewController animated:YES];


You should do it like this.

webView.navigationItem.rightBarButtonItem = doneButton;


Try to add the doneButton to your UIViewController, then you should be fine.


Maybe you should change webView to webViewController, a better name.

0

精彩评论

暂无评论...
验证码 换一张
取 消