只有一个window根控制器,,没有其他的UIView,现在在window页面上添加一个按钮,点击按钮想跳转到下一个页面(dataManage.xib)我是如下实现的:
iFrameExtractorAppDelegate.h 文件:
@property (nonatomic,retain) UINavigationController *navigationController;iFrameExtractorAppDelegate.m文件:
- (void)applicationDidFinishLaunching:(UIApplication *)application {
// UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:self.window.rootViewController];
// self.window.rootViewController = nav; //-----------注释这一部分不能实现跳转
UINavigationController *nav = [[UINavigationController alloc] init];
[self.window.rootViewController addChildViewController:nav]; //-----------这样做同样不行
}
跳转到下一个页面代码:
//点击按钮触发的函数(数据菜单管理)
-(IBAction)dataManage{
dataManage *dataManagePage = [[dataManage alloc] initWithNibName:@"dataManage" bundle:nil];
[self.navigationController pushViewController:dataManagePage animated:YES];
NSLog(@"fuck jump.....");
}
附注:
MainWinow.xib如下:UIWindow页面跳转ios
iFrameExtractorAppDelegate.h 文件:
@property (nonatomic,retain) UINavigationController *navigationController;iFrameExtractorAppDelegate.m文件:
- (void)applicationDidFinishLaunching:(UIApplication *)application {
// UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:self.window.rootViewController];
// self.window.rootViewController = nav; //-----------注释这一部分不能实现跳转
UINavigationController *nav = [[UINavigationController alloc] init];
[self.window.rootViewController addChildViewController:nav]; //-----------这样做同样不行
}
跳转到下一个页面代码:
//点击按钮触发的函数(数据菜单管理)
-(IBAction)dataManage{
dataManage *dataManagePage = [[dataManage alloc] initWithNibName:@"dataManage" bundle:nil];
[self.navigationController pushViewController:dataManagePage animated:YES];
NSLog(@"fuck jump.....");
}
附注:
MainWinow.xib如下:UIWindow页面跳转ios
解决方案 »
- 申请ios开发者账号的时候有一项不会填
- 在 init方法中调用NSLog输出没有用??????
- 小弟刚开始研究ios,怎么连接以及建立sqlite数据库,谢谢!
- 在主线程中如何判断SOAP读取Webservice数据结束?
- iphone多线程(问题困扰几个月了,跪求高手指点)
- 会说话的tom猫是怎么实现的呢!!!
- UIWindow的问题
- IOS跳转到新页面后没有进行网络请求是什么情况?
- IOS开发 后台运行的APP获取系统的剪贴板事件和内容
- 在iPhone Safari打开https服务器上企业内部发布的IPA,无法连接到“xx.xx.x”IP地址
- iOS socket通信问题 接收函数实在是看不明白
- window里面点击一个button按钮实现页面跳转???
{
UINavigationController * nav;
}@property (strong, nonatomic) UIWindow *window;@end
. m#import "AppDelegate.h"
#import "SecondViewController.h"@implementation AppDelegate- (void)dealloc
{
[_window release];
[nav release];
[super dealloc];
}- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
// Override point for customization after application launch.
self.window.backgroundColor = [UIColor whiteColor];
UIViewController *vc = [[UIViewController alloc] init];
vc.view.backgroundColor =[UIColor yellowColor];
UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(90, 100, 140, 40)];
btn.backgroundColor = [UIColor redColor];
[btn addTarget:self action:@selector(btnClick) forControlEvents:UIControlEventTouchUpInside];
[vc.view addSubview:btn];
[btn release];
nav = [[UINavigationController alloc] initWithRootViewController:vc];
self.window.rootViewController = nav;
[vc release];
[self.window makeKeyAndVisible];
return YES;
}- (void)btnClick
{
UIViewController *vc = [[UIViewController alloc] initWithNibName:@"second" bundle:nil];
[nav pushViewController:vc animated:YES];
[vc release];
}- (void)applicationWillResignActive:(UIApplication *)application
{}- (void)applicationDidEnterBackground:(UIApplication *)application
{}- (void)applicationWillEnterForeground:(UIApplication *)application
{}- (void)applicationDidBecomeActive:(UIApplication *)application
{}- (void)applicationWillTerminate:(UIApplication *)application
{}@end
看如下图片:同样是改不了,就算是强制写UIViewController也不能改
/* 错误
UIViewController *dataManage = [[UIViewController alloc] initWithNibName:@"dataManage" bundle:nil];
UINavigationController *nav1 = [[UINavigationController alloc] initWithRootViewController:dataManage];
self.window.rootViewController = nav1;
*/
}然后,,编译就不通过了,,出错了。项目我已经上传到百度网盘:http://pan.baidu.com/s/1zLPD9 (大神如果有空的话,,麻烦帮看一下,不甚感激!!)
我只是一个菜鸟,XCode环境不一样,不好帮你看啊,并且如果是编译错误,不是LINK错误,最好还是自己修改吧
[vc1.navigationController pushViewController:vc2 animated:YES];你需要注意的是,其中vc1必须是在导航控制器栈中,不是所有的控制器通过上述的代码都可以导航视图。
你贴出的代码中就出现了这种认识上的错误。
首先一个App应用理论上来说只有一个window.但可以有多个视图控制器。所以一般的我们不会把我们的内容直接放到window上,而是创建一个视图控制器,在这个视图上来添加你的视图元素。因此,uiwindow有一个rootviewcontroller的属性,就是让我们在这里指定我们的根控制器,因为也只有视图控制器有进行视图导航的能力。
- (void)applicationDidFinishLaunching:(UIApplication *)application {
UIViewController *vc1=[[UIViewController alloc] init];
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc1];
self.window.rootViewController = nav;
}
我们通过uinavigationcontroller 封装了vc1,生成了一个新的导航控制器,且它为导航控制器的根控制器,这时在vc1中触发导航到vc2的代码的话,就不会再有问题了