1
長話短說iOS10左側,右側按鈕,自定義標籤沒有問題,iOS11沒有顯示。我在其他地方看過,我需要爲按鈕添加約束條件,但這沒有幫助。在viewDidLoad()
中調用的代碼。UIBarButtonItem不能在ios11中工作
self.connectionButton = [[UIButton alloc] initWithFrame:CGRectMake(0.0,0.0,74.0,29.0)];
[self.connectionButton.widthAnchor constraintEqualToConstant:74].active = YES;
[self.connectionButton.heightAnchor constraintEqualToConstant:29].active = YES;
self.connectionButton.backgroundColor = [UIColor yellowColor];
UIBarButtonItem *buttonItem = [[UIBarButtonItem alloc] initWithCustomView:self.connectionButton];
self.navigationItem.rightBarButtonItem = buttonItem;
外觀:
[[UINavigationBar appearance] setTranslucent:YES];
[[UINavigationBar appearance] setShadowImage:[UIImage new]];
[[UINavigationBar appearance] setBackgroundImage:[UIImage new] forBarPosition:UIBarPositionAny barMetrics:UIBarMetricsDefault];
[[UINavigationBar appearance] setBackgroundColor:[UIColor clearColor]];
當我檢查在運行時框架是正確的(0,0,74,29)。雖然沒有按鈕顯示在欄中。
XCode 9 beta 8,不能在任何設備或模擬器上工作。
請分享您的完整NavBar設置(外觀配置等)。你在哪種方法設置rightBarButtonItem? –
已編輯。 Afaik沒什麼特別的,默認在故事板上用於根控制器。 – Tom
我也有同樣的問題,在ios11 barbuton時間iboutlet不工作...它顯示不是密鑰值編碼兼容的關鍵,任何幫助 – Tech