UINavigationController不起作用

UINavigationController不起作用

我在应用程序中使用了UITabBar,但是(由于我自己的原因)我必须将其删除。现在我的UINavigationControllers都不工作。最明显的地方是当我打电话:[self.navigationController pushViewController:myViewController animated:YES];

该代码现在什么也不做,因为我没有UINavigationController,而且我不知道如何制作一个可以工作的代码。

最佳答案

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    //Initialize window components
    UINavigationController *myNavController     = [[UINavigationController alloc] init];
    [self setNavController: myNavController];
    [myNavController release];

    FirstViewController *cViewController    = [[FirstViewController alloc] init];
    [self setMyFirstView: cViewController];
    [cViewController release];

    [self.window addSubview: [self navController].view];

    [[self navController] pushViewController: myFirstView animated:YES];

    [self.window makeKeyAndVisible];
    return YES;
}


这应该可以解决问题。

顺便说一句,您应该在proxy.h中声明以下内容:

@property (nonatomic, retain) UINavigationController *navController;
@property (nonatomic, retain) IBOutlet CatchengoViewController *viewController;
@property (nonatomic, retain) UIViewController *myFirstView;

关于iphone - UINavigationController不起作用,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/6587749/

10-13 08:02