【发布时间】:2012-08-14 19:42:36
【问题描述】:
在视图控制器加载的视图中,我使用图像自定义标题视图:
self.navigationItem.titleView = [[UIImageView alloc] initWithImage: [UIImage imageNamed: @"navigationBarCentralImage.png"]];
到目前为止一切顺利,它在导航栏的中心显示图像。 但是,当我弹出当前视图并推送一个在没有自定义标题视图的情况下运行良好的新视图时,它会崩溃。 这是我用来弹出/推送的代码
-(void)popLastViewAndPush:(id)viewController
{
NSMutableArray *controllers = [SharedAppDelegate.navigationController.viewControllers mutableCopy];
if([controllers objectAtIndex:[controllers count] -1] == viewController)
return;
[controllers removeLastObject];
SharedAppDelegate.navigationController.viewControllers = controllers;
[SharedAppDelegate.navigationController pushViewController:viewController animated:YES];
}
我有点卡住了,不明白为什么它实际上会因标题视图自定义而崩溃
【问题讨论】:
-
如果注释掉标题视图自定义,是否会发生崩溃?即:这实际上是导致它的原因吗?
-
是的,如果我评论 self.navigationItem.titleView 行,不会崩溃!否则这篇文章的实际意义是什么?
标签: objective-c uinavigationbar uinavigationitem