在 iPhone 中使用 modalView 将 barButtons 添加到导航栏
在我的应用程序中,我呈现了一个顶部带有导航栏的 modalViewController,但我无法将栏按钮添加到导航栏。我正在使用以下代码:
displayController = [[UIViewController alloc]initWithNibName:nil bundle:nil];
UINavigationController *cntrol = [[UINavigationController alloc] initWithRootViewController:displayController];
[displayController setTitle:@"TEST"];
UIBarButtonItem *submit = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemDone
target:self
action:@selector(displayViewForPosts)];
displayController.navigationItem.rightBarButtonItem = submit;
[submit release];
UIBarButtonItem *newsfeed = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemDone
target:self
action:@selector(displayViewForPosts)];
displayController.navigationItem.leftBarButtonItem = newsfeed;
[newsfeed release];
[self presentModalViewController:cntrol animated:YES];
[cntrol release];
[displayController release];
In my application, I'm presenting a modalViewController with a navigationbar on the top of it, but I'm not able to add barbuttons to the navigatiobar. I'm using following code:
displayController = [[UIViewController alloc]initWithNibName:nil bundle:nil];
UINavigationController *cntrol = [[UINavigationController alloc] initWithRootViewController:displayController];
[displayController setTitle:@"TEST"];
UIBarButtonItem *submit = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemDone
target:self
action:@selector(displayViewForPosts)];
displayController.navigationItem.rightBarButtonItem = submit;
[submit release];
UIBarButtonItem *newsfeed = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemDone
target:self
action:@selector(displayViewForPosts)];
displayController.navigationItem.leftBarButtonItem = newsfeed;
[newsfeed release];
[self presentModalViewController:cntrol animated:YES];
[cntrol release];
[displayController release];
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)