是否可以使presentModalViewController成为UINavigation控制器?

时间:2011-04-25 04:46:27

标签: iphone ios uinavigationcontroller presentmodalviewcontroller

我正在尝试在启动应用程序时启动presentModalViewController。我可以使presentModalViewController正常,但当我尝试使它成为UINavigation控制器时,我看到的只是一个空白的UINavigationController。

我的课程概述定义如下:

#import <UIKit/UIKit.h>
@class Login;

@interface Overview : UINavigationController {

}

-(IBAction) btnRegistrationPressed;
-(IBAction) btnLoginPressed;


@end

然后在委托中我这样做:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    

    // Override point for customization after application launch.

    // Add the tab bar controller's view to the window and display.
    [self.window addSubview:tabBarController.view];

    Overview *overviewViewController = [[Overview alloc] initWithNibName:@"Overview" bundle:nil];

    [self.tabBarController presentModalViewController:overviewViewController animated:YES];
    [overviewViewController release];
    [self.window makeKeyAndVisible];

    return YES;
}

我还有一个Overview.xib,我从库中拖入UiNavigation Controller。下面的视图控制器设置为一个名为test的类,它将在屏幕上显示一条消息。

当我启动时,我看到的只是一个空白的UINavigationController。

有什么想法吗?

1 个答案:

答案 0 :(得分:3)

您是否尝试过以下

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    

// Override point for customization after application launch.

// Add the tab bar controller's view to the window and display.
[self.window addSubview:tabBarController.view];


Overview *overviewViewController = [[Overview alloc] initWithNibName:@"Overview" bundle:nil];

 UINavigationController *nav_obj = [[UINavigationController alloc] initWithRootViewController:overviewViewController ];

[self.tabBarController presentModalViewController:nav_obj  animated:YES];
[overviewViewController release];
[self.window makeKeyAndVisible];

return YES;

}