经过数小时的不成功研究,这是我的问题。
自我的应用开发开始以来,navigationBar.topItem.title
无法正常工作,所以我决定创建自己的子类,但仍然存在问题。
这是我的代码:
- (id)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
NSLog(@"NavBar Ready !");
self.topItem.title = @"something";
NSLog(@"%@", self.class);
NSLog(@"%@", self.topItem.class);
NSLog(@"%@", self.topItem.title.class);
}
return self;
}
以下是控制台输出,正如您所看到的,topItem
类存在问题,但此属性为只读,因此我可以' t alloc
和init
任意UINavigationItem
。
2014-03-13 17:25:34.063 CCE[63471:60b] NavBar Ready !
2014-03-13 17:25:34.064 CCE[63471:60b] CCENavigationBar
2014-03-13 17:25:34.065 CCE[63471:60b] (null)
2014-03-13 17:25:34.065 CCE[63471:60b] (null)
所以这是我的问题...... 发生了什么,我该怎么做才能解决它?
谢谢你们SO社区!
答案 0 :(得分:2)
在我的项目中(使用故事板),如果我设置了嵌入在NavigationController中的ViewControllers:
self.title= @"title";
设置导航栏的标题。你试过这样设置吗?