![](/img/trans.png)
[英]How to custom in storyboard my view controller's UINavigationItem that is instantiated by identifier and pushed onto navigation stack?
[英]UINavigationItem's title disappears when view controller is pushed
我的視圖控制器的導航項的標題有問題。 確實,我是在viewDidLoad
方法中設置的,如下所示:
self.navigationItem.title = "Title"
問題是,當我將該視圖控制器從另一個推入導航堆棧時,我在過渡時看到標題,但是一旦過渡結束,它便消失了……我在調試器中簽入后,標題仍處於設置狀態。 ..我嘗試使用titleView屬性還是沒有成功...順便說一句,問題僅在iOs <9的iPhone 5上出現...
讓我們嘗試作為答案: CGSize result = [[UIScreen mainScreen] bounds].size; _navBar = [[UINavigationBar alloc] initWithFrame:CGRectMake(0,0, result.size.width, 40)]; _navItem = [[UINavigationItem alloc] initWithTitle:@"Title"]; [_navBar setItems:@[_navItem]]; [self.view addSubview:_navBar];
CGSize result = [[UIScreen mainScreen] bounds].size; _navBar = [[UINavigationBar alloc] initWithFrame:CGRectMake(0,0, result.size.width, 40)]; _navItem = [[UINavigationItem alloc] initWithTitle:@"Title"]; [_navBar setItems:@[_navItem]]; [self.view addSubview:_navBar];
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.