我已经回到hello world tutorials试图做到这一点。我似乎无法理解这一点,但它应该如此简单。使用UINavigationBar在视图之间切换
我想要在右侧有一个按钮的UINavigationBar。当用户按下此按钮时,它将通过滑动到边的动画将它们带到第二个视图,并且在这个新视图上,导航栏显示前一个视图的后退按钮。
我怎么能得到这个发生?我不能为我的生活弄清楚。有没有一个教程在哪里可以找到它?我找不到一个。
我已经回到hello world tutorials试图做到这一点。我似乎无法理解这一点,但它应该如此简单。使用UINavigationBar在视图之间切换
我想要在右侧有一个按钮的UINavigationBar。当用户按下此按钮时,它将通过滑动到边的动画将它们带到第二个视图,并且在这个新视图上,导航栏显示前一个视图的后退按钮。
我怎么能得到这个发生?我不能为我的生活弄清楚。有没有一个教程在哪里可以找到它?我找不到一个。
在按钮操作(选择器)使用下面的消息上self.navigationController
pushViewController:secondViewController animated:YES
编辑:创建的UINavigationController如下:
UINavigationController* navController = [[UINavigationController alloc] initWithRootViewController:rootViewController];
然后设置右按钮根据需要索林在他的回答中建议。并且在我的原始答案中已经发布了在self.navigationController上使用pushViewController:animated:消息。希望能帮助到你。 rootViewController是您希望作为导航堆栈上的第一个视图推送的视图控制器。
您应该以UIViewController作为根创建一个UINavigationController。在UIViewController中,你应该设置栏右键。你应该有一些与此类似:
self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc]
initWithTitle: @"Next"
style:UIBarButtonItemStyleDone
target:self
action:@selector(nextPage:)]
autorelease];
当你触摸按钮的方法下一页:将被调用,将执行新的视图的推动。
-(void)nextPage:(id)sender
{
UIViewController *secondViewController = [[UIViewController alloc] init];
[self.navigationController pushViewController:secondViewController animated:YES];
[secondViewController release];
}
这里是使用UINavigationController和here两个部分教程是为UINavigationController的(真的很有用)的官方文档。
解决了这个问题 - 谢谢。我留下的问题是如何制作导航控制器,以及如何确保它出现在这些视图上?我对此毫不知情。 – Andrew 2011-03-08 19:46:11
看到我上面的编辑 – Bourne 2011-03-08 20:42:11