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は、デバイスやシミュレータでは動作しません。

+0

完全なNavBarセットアップ(外観設定など)を共有してください。どのメソッドで、あなたはrightBarButtonItemを設定していますか? –

+0

編集されました。 Afaikは何も特別ではないが、ルートコントローラのストーリーボードにはデフォルトが設定されている。 – Tom

+0

ios11 barbutonで同じ問題が発生しました。iboutletは機能しません...キーに対応しているキー値、何らかのヘルプ – Tech

答えて

0

多くのテストで、ナビゲーションバーには何も表示されないことがわかりました。デフォルトの外観でもタイトルは表示されません。無関係なコードのコメント/コメントを解除枚に無駄な時間、私は犯人を見つけた後:

override var traitCollection: UITraitCollection { 
     var horizTraitCollection = UITraitCollection(horizontalSizeClass: .regular) 
     if view.bounds.width < view.bounds.height { 
      horizTraitCollection = UITraitCollection(horizontalSizeClass: .compact) 
     } 

     return UITraitCollection(traitsFrom: [horizTraitCollection, UITraitCollection(verticalSizeClass: super.traitCollection.verticalSizeClass)]) 
    } 

これは私がポートレート/風景プレゼンテーションにオーバーライドサイズクラスを使用しているものです。 IMOはナビゲーションバーの外観とはまったく無関係です。なぜそれがナビゲーションバーを壊しているのか、それを修正する方法は考えられません。

編集:私はそれをiPhoneではなくiPhoneで動作させることができました。もう少し微調整をしてから、私はiPhoneでも同様に作業しています。

override var traitCollection: UITraitCollection { 
    if UIDevice.current.userInterfaceIdiom == .pad { 
     var horizTraitCollection = UITraitCollection(horizontalSizeClass: .regular) 
     if UIDevice.current.orientation.isPortrait { 
      horizTraitCollection = UITraitCollection(horizontalSizeClass: .compact) 
     } 
     return UITraitCollection(traitsFrom: [horizTraitCollection, UITraitCollection(verticalSizeClass: super.traitCollection.verticalSizeClass)]) 
    } 
    return super.traitCollection 
} 
関連する問題