大佬教程收集整理的这篇文章主要介绍了iphone – 在UINavigationController中推送另一个视图?,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
这正是我需要的,我有一个带有4个选项卡的UITabBarController,其中一个是UINavigationController.我想从第一个视图推送包含导航控制器的视图 – 这是一个简单的UIView.它不起作用,我尝试使用以编程方式创建的按钮,没有任何反应.有什么指针吗?
这是我的代码
@interface HomeViewController : UIViewController { } -(IBACtion)pushViewController:(id)sender; @end --- #import "HomeViewController.h" #import "NewViewController.h" @implementation HomeViewController -(IBACtion)pushViewController:(id)sender { NewViewController *controller = [[NewViewController alloc] initWithNibName:@"NewViewController" bundle:nil]; [[self navigationController] pushViewController:controller animated:YES]; [controller release],controller = nil; }
这里还有连接的屏幕截图
http://imageshack.us/photo/my-images/847/screenshot20110719at620.png/
我已经尝试过你们建议但仍然没有,按钮(无论它们是在Interface Builder中创建还是以编程方式创建)就像它们没有链接到任何方法一样.
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect]; button.frame = CGRectMake(100.0,100.0,40.0); [button settitle:@"Press" forState:UIControlStateNormal]; [viewController.view addSubview:button]; [button addTarget:self action:@SELEctor(didPressButton:) forControlEvents:UIControlEventTouchUpInside];
并实现此方法:
- (void)didPressButton:(UIButton *)sender { UIViewController *viewController = [[[UIViewController alloc] init] autorelease]; [self.navigationController pushViewController:viewController animated:YES]; }
以上是大佬教程为你收集整理的iphone – 在UINavigationController中推送另一个视图?全部内容,希望文章能够帮你解决iphone – 在UINavigationController中推送另一个视图?所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。