self.navigationController 为空,在MasterViewController 不同的方法里



 - (void)viewDidLoad{
    [super viewDidLoad];
    self.navigationItem.title = @"Order List";
    self.tb.enableAppend = YES;
    self.tb.enableRefresh = YES;
    self.tb.RADelegate = self;
    self.automaticallyAdjustsScrollViewInsets = NO;
    ManagerSiteTableViewController *managerSite = [ManagerSiteTableViewController sharedLeftTableViewController];
    managerSite.delegate = self;

    UIBarButtonItem *leftMenu = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"reveal-icon.png"]
                                                                 style:UIBarButtonItemStyleBordered
                                                                target:self
                                                                action:@selector(leftMenu)];
    self.navigationItem.leftBarButtonItem = leftMenu;

    NSLog(@"nav:%@",self.navigationController);
    [self.revealSideViewController setDirectionsToShowBounce:PPRevealSideDirectionLeft];
}

-(void)leftTableViewController:(ManagerSiteTableViewController *)leftTableViewController pushViewController:(UIViewController *)pushVC{
    NSLog(@"pushVC:%@",self.navigationController);

    [self.navigationController pushViewController:pushVC animated:YES];
}

self.navigationController 在viewDidLoad里显示是正常的
但在下面的那个方法里就为空,这是什么原因?

ios objective-c

朱雀小路纱魅 10 years, 4 months ago

下面那个方法在什么情况下会被执行到啊?只有在当前的viewcontroller是在一个navigation controller里的时候, 它的navigationController属性才是非nil的, 如果当前viewcontroller已经被pop出去了, 那navigationController就是nil了。

被封印的ID answered 10 years, 4 months ago

Your Answer