2017-10-01 4 views
0

내 화면이 어떻게 보이게되어 있습니다. 맨 아래에 UIToolBar가 있고 UIBarButtonItem이 있습니다. 그것은iOS 11 : UIToolbar 내부의 UIBarButtonItem이 자리를 비 웁니다.

enter image description here

그러나 아이폰 OS 11에서 UIBarButtonItem 그 자리를 보여주는 아이폰 OS (11) 전에 잘 전에 작업을했다. 상태 표시 줄에 표시됩니다. 시뮬레이터에서 잘 작동하고 툴바 안에 표시됩니다. 하지만 iOS 11을 실행하는 iPhone 6에서 실행할 때 아래 화면과 같습니다.

enter image description here

여기

public override void ViewDidAppear(bool animated) 
{ 
    base.ViewDidAppear(animated); 
    UIBarButtonItem[] bArray = { 
     getSetAsHomeButton(apiCall, this, 0), 
     new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace) 
    }; 
    SetToolbarItems(bArray, true); 
} 

public static UIBarButtonItem getSetAsHomeButton(ICommonApiCall commonApiCall, UIViewController controller, int status) 
{ 
    var view = new UIButton(); 
    view.Layer.CornerRadius = 8; 
    view.BackgroundColor = UIColor.White; 

    view.TranslatesAutoresizingMaskIntoConstraints = false; 
    view.WidthAnchor.ConstraintEqualTo(108).Active = true; 
    view.HeightAnchor.ConstraintEqualTo(32).Active = true; 

    var HomeIcon = new UILabel (new RectangleF (0, 0, 21, 21)); 
    HomeIcon.Font = FontAwesome.Font (22); 
    HomeIcon.Text = FontAwesome.FAHome; 
    HomeIcon.TextColor = PlatformConstants.PrimaryColor; 

    var HomeLabel = new UILabel (new RectangleF (25, 0, 64, 44)); 
    HomeLabel.Text = "Set as default"; 
    HomeLabel.Font = UIFont.FromName (PlatformConstants.PrimaryFont + "-Medium", 11); 
    HomeLabel.TextColor = PlatformConstants.PrimaryColor; 
    HomeLabel.Lines = 0; 
    HomeLabel.SizeToFit(); 

    view.AddSubview (HomeIcon); 
    view.AddSubview (HomeLabel); 

    HomeIcon.TranslatesAutoresizingMaskIntoConstraints = false; 
    HomeLabel.TranslatesAutoresizingMaskIntoConstraints = false; 

    var hSpaceLeading = NSLayoutConstraint.Create (HomeIcon, NSLayoutAttribute.Leading, 
            NSLayoutRelation.Equal, view, NSLayoutAttribute.Leading, 1, 6); 
    view.AddConstraint (hSpaceLeading); 

    var HomeIconCenterY = NSLayoutConstraint.Create (HomeIcon, NSLayoutAttribute.CenterY, 
           NSLayoutRelation.Equal, view, NSLayoutAttribute.CenterY, 1, 0); 
    view.AddConstraint (HomeIconCenterY); 

    var HomeLabelCenterY = NSLayoutConstraint.Create (HomeLabel, NSLayoutAttribute.CenterY, 
           NSLayoutRelation.Equal, view, NSLayoutAttribute.CenterY, 1, 0); 
    view.AddConstraint (HomeLabelCenterY); 

    var hSpace = NSLayoutConstraint.Create (HomeLabel, NSLayoutAttribute.Left, 
          NSLayoutRelation.Equal, HomeIcon, NSLayoutAttribute.Right, 1, 4); 
    view.AddConstraint (hSpace); 

    var HomeLabelWidth = NSLayoutConstraint.Create (HomeLabel, NSLayoutAttribute.Width, 
           NSLayoutRelation.Equal, null, NSLayoutAttribute.NoAttribute, 1, 80); 
    view.AddConstraint (HomeLabelWidth); 

    view.LayoutIfNeeded(); 

    view.TouchUpInside += delegate { 
     SetAsHome (commonApiCall, controller, status, view).ContinueWith (t => Console.WriteLine (t.Exception), 
            TaskContinuationOptions.OnlyOnFaulted); 
    }; 

    return new UIBarButtonItem (view); 
} 

어떤 도움에 감사드립니다 .. 코드입니다. 고맙습니다.

답변

1

iOS 자동 레이아웃이 UINavigationBar 및 UIToolbar 요소에 도입 되었기 때문에. 따라서 문제를 해결하는 가장 좋은 방법은 적절한 제약 조건을 추가하는 것입니다. 이 방법으로 문제가 해결 https://forums.developer.apple.com/thread/80075

희망 :

는 여기에서 문제에 좀 더 도움과 정보를 찾을 수 있습니다.

관련 문제