只有一个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

解决方案 »

  1.   

    .h#import <UIKit/UIKit.h>@interface AppDelegate : UIResponder <UIApplicationDelegate>
    {
        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
      

  2.   

    需要注意,自己加的nib文件,需要设置File's Owner 的class 为UIViewController,并且重新连接UIView
      

  3.   

    File's Owner 的class 为UIWindow,,改不了UIViewController,,你上面说的这种方法是一般的那种跳转方法,我之前就一直是这样用的,,,不过这种方法在这个demo中不能实现跳转,之前试过了。
      

  4.   

    File's Owner 的class 为UIWindow,,改不了UIViewController,,你上面说的这种方法是一般的那种跳转方法,我之前就一直是这样用的,,,不过这种方法在这个demo中不能实现跳转,之前试过了。我说的修改的NIB文件指的是dataManage这个文件,这个是可以修改的啊,并且按我给的代码是可以跳转的
      

  5.   

    File's Owner 的class 为UIWindow,,改不了UIViewController,,你上面说的这种方法是一般的那种跳转方法,我之前就一直是这样用的,,,不过这种方法在这个demo中不能实现跳转,之前试过了。我说的修改的NIB文件指的是dataManage这个文件,这个是可以修改的啊,并且按我给的代码是可以跳转的
    看如下图片:同样是改不了,就算是强制写UIViewController也不能改
      

  6.   

    第二列中,你要选中File's Owner啊,你先看清我二楼的回复
      

  7.   

    哦哦,,我按照你的方法将File's Owner 的类改为了 UIViewController 了,,自己也改了一点东西,- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
    /* 错误
        UIViewController *dataManage = [[UIViewController alloc] initWithNibName:@"dataManage" bundle:nil];
        UINavigationController  *nav1 = [[UINavigationController alloc] initWithRootViewController:dataManage];
        self.window.rootViewController = nav1;
        
    */
    }然后,,编译就不通过了,,出错了。项目我已经上传到百度网盘:http://pan.baidu.com/s/1zLPD9  (大神如果有空的话,,麻烦帮看一下,不甚感激!!)
      

  8.   


    我只是一个菜鸟,XCode环境不一样,不好帮你看啊,并且如果是编译错误,不是LINK错误,最好还是自己修改吧
      

  9.   

    你对基础知识的理解没有弄清楚如果使用导航控制器来导航你的视图,如下代码:
    [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的代码的话,就不会再有问题了