开发者

Right button not appearing on modal view controller

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜