UIAlertControllerInterfaceActionGroupView AMBIGUOUS LAYOUT

レイモンドヒル

を提示するときに制約の問題を理解しようとしていますUIAlertController

2019-04-26 11:40:42.140007 + 0100 MyAPP [12811:3974220] [LayoutConstraints]制約を同時に満たすことができません。おそらく、次のリストの制約の少なくとも1つは不要なものです。これを試してください:(1)各制約を見て、予期しないものを見つけ出してください。(2)不要な制約を追加したコードを見つけて修正します。( "")制約を解除して回復を試みますUIViewAlertForUnsatisfiableConstraintsでシンボリックブレークポイントを作成して、デバッガーでこれをキャッチします。にリストされているUIViewのUIConstraintBasedLayoutDebuggingカテゴリのメソッドも役立つ場合があります。

UIAlertController以下の関数を使用して作成し、提示します

@discardableResult
static func showOptionsModal(withOptions options:[String], sender:UIViewController ,holderView:UIView, arrowPosition:UIPopoverArrowDirection, completion: ((_ option:Int) -> ())?)->UIAlertController {

    let moreActionsCellSheetController = UIAlertController(title:nil, message: nil,preferredStyle: .actionSheet)

    for (i, option) in options.enumerated(){

        let optionAction = UIAlertAction(title:option, style: .default){ (_) in
            completion?(i)
        }
        moreActionsCellSheetController.addAction(optionAction)

    }

    if UIDevice.current.userInterfaceIdiom != .pad {
        let actionCancel = UIAlertAction(title:printLocalized(withKey: "messages.cancel", targetSpecific: false), style: .destructive){ (_) in
            completion?(-1)
        }
        moreActionsCellSheetController.addAction(actionCancel)
    }


    moreActionsCellSheetController.view.tintColor = UIColor.black

    moreActionsCellSheetController.popoverPresentationController?.sourceView = holderView
    moreActionsCellSheetController.popoverPresentationController?.sourceRect = holderView.frame

    switch arrowPosition {
    case .up:
        moreActionsCellSheetController.popoverPresentationController?.sourceRect.origin.y = 0
        moreActionsCellSheetController.popoverPresentationController?.sourceRect.origin.x = (-holderView.frame.width / 8)
        moreActionsCellSheetController.popoverPresentationController?.permittedArrowDirections = .up
    case .right:
        moreActionsCellSheetController.popoverPresentationController?.sourceRect.origin.y = 0
        moreActionsCellSheetController.popoverPresentationController?.sourceRect.origin.x = 0
        moreActionsCellSheetController.popoverPresentationController?.permittedArrowDirections = .right
    case .down:
        moreActionsCellSheetController.popoverPresentationController?.sourceRect.origin.y = holderView.bounds.width/2
        moreActionsCellSheetController.popoverPresentationController?.permittedArrowDirections = .down
    case .left:
        moreActionsCellSheetController.popoverPresentationController?.sourceRect.origin.y = holderView.bounds.height/2
        moreActionsCellSheetController.popoverPresentationController?.permittedArrowDirections = .left
    default:
        moreActionsCellSheetController.popoverPresentationController?.sourceRect.origin.y = 0
        moreActionsCellSheetController.popoverPresentationController?.sourceRect.origin.x = 0
        moreActionsCellSheetController.popoverPresentationController?.permittedArrowDirections = .any
    }

    sender.present(moreActionsCellSheetController,animated: true, completion: nil)

    return moreActionsCellSheetController

}

シンボリックブレークポイントが追加され、次のようなアクションが追加されました。 シンボリックブレークポイント

autolayoutTraceは、次の結果を示します。

•UIWindow:0x159d197b0 - AMBIGUOUS LAYOUT
|   •UIView:0x159d3fbf0
|   |   *<UILayoutGuide: 0x2817eda40 - "UIViewSafeAreaLayoutGuide", layoutFrame = {{0, 44}, {375, 734}}, owningView = <UIView: 0x159d3fbf0; frame = (0 0; 375 812); autoresize = W+H; tintColor = UIExtendedSRGBColorSpace 0.176471 0.176471 0.176471 1; layer = <CALayer: 0x282ec41a0>>>
|   |   *UIView:0x159d367d0
|   |   |   UILayoutContainerView:0x159d580b0
|   |   |   |   UINavigationTransitionView:0x159d5a760
|   |   |   |   |   UIViewControllerWrapperView:0x159d4e880
|   |   |   |   |   |   •UIView:0x15b403b70
|   |   |   |   |   |   |   *<UILayoutGuide: 0x2817fd5e0 - "UIViewSafeAreaLayoutGuide", layoutFrame = {{0, 0}, {375, 640}}, owningView = <UIView: 0x15b403b70; frame = (0 44; 375 640); autoresize = W+H; tintColor = UIExtendedSRGBColorSpace 0.176471 0.176471 0.176471 1; layer = <CALayer: 0x282e8ad20>>>
|   |   |   |   |   |   |   *DAT_Air_Vinyl.MainLabel:0x15b503030'Select device to connect ...'
|   |   |   |   |   |   |   *UIScrollView:0x15c014c00
|   |   |   |   |   |   |   |   *<_UIScrollViewContentOffsetGuide: 0x2817ecfc0 - "UIScrollView-contentOffsetLayoutGuide", layoutFrame = {{0, 0}, {0, 0}}, owningView = <UIScrollView: 0x15c014c00; frame = (0 0; 375 640); clipsToBounds = YES; hidden = YES; autoresize = RM+BM; gestureRecognizers = <NSArray: 0x282079e00>; layer = <CALayer: 0x282e8ce00>; contentOffset: {0, 0}; contentSize: {375, 746}; adjustedContentInset: {0, 0, 0, 0}>>
|   |   |   |   |   |   |   |   *DAT_Air_Vinyl.RecordHeaderView:0x15b503320
|   |   |   |   |   |   |   |   |   *DAT_Air_Vinyl.RecordHeaderView:0x15b406010
|   |   |   |   |   |   |   |   |   |   *<UILayoutGuide: 0x2817e5a40 - "UIViewSafeAreaLayoutGuide", layoutFrame = {{0, 0}, {375, 150}}, owningView = <DAT_Air_Vinyl.RecordHeaderView: 0x15b406010; frame = (0 0; 375 150); clipsToBounds = YES; autoresize = RM+BM; layer = <CALayer: 0x282e8b120>>>
|   |   |   |   |   |   |   |   |   |   *UIView:0x15b406240
|   |   |   |   |   |   |   |   |   |   |   *DAT_Air_Vinyl.MainButton:0x15b406420'Enable'
|   |   |   |   |   |   |   |   |   |   |   |   UIImageView:0x159d74e80
|   |   |   |   |   |   |   |   |   |   |   |   UIButtonLabel:0x15b406950'Enable'
|   |   |   |   |   |   |   |   |   |   |   *DAT_Air_Vinyl.MainView:0x15b4070b0
|   |   |   |   |   |   |   |   |   |   |   |   *DAT_Air_Vinyl.MainLabel:0x15b4075f0'Gain:'
|   |   |   |   |   |   |   |   |   |   |   |   *DAT_Air_Vinyl.SelectorDropDownView:0x15b407ae0
|   |   |   |   |   |   |   |   |   |   |   |   |   *UIImageView:0x15b604f90
|   |   |   |   |   |   |   |   |   |   |   |   |   *DAT_Air_Vinyl.MainLabel:0x15b60aa20'0 dB'
|   |   |   |   |   |   |   |   |   |   |   *DAT_Air_Vinyl.MainButton:0x15b4041a0'Clear all'
|   |   |   |   |   |   |   |   |   |   |   |   UIImageView:0x159d79740
|   |   |   |   |   |   |   |   |   |   |   |   UIButtonLabel:0x15b4046d0'Clear all'
|   |   |   |   |   |   |   |   |   |   *UIView:0x15b508ed0
|   |   |   |   |   |   |   |   |   *UIView:0x15b50d250
|   |   |   |   |   |   |   |   *DAT_Air_Vinyl.MainTableView:0x15c025c00
|   |   |   |   |   |   |   |   |   UIView:0x15b5084d0
|   |   |   |   |   |   |   |   |   UIImageView:0x159d767c0
|   |   |   |   |   |   |   |   |   UIImageView:0x159d769f0
|   |   |   |   |   |   |   |   UIImageView:0x159d76f70
|   |   |   |   |   |   |   |   UIImageView:0x159d76d40
|   |   |   |   |   |   |   *_TtCC13DAT_Air_Vinyl20SelectorDropDownView12DropDownView:0x15b509420
|   |   |   |   |   |   |   |   *DAT_Air_Vinyl.MainTableView:0x15c026800
|   |   |   |   |   |   |   |   |   UIView:0x15b50a210
|   |   |   |   |   |   |   |   |   UIImageView:0x159d7a740
|   |   |   |   UINavigationBar:0x159d582b0
|   |   |   |   |   _UIBarBackground:0x159d58770
|   |   |   |   |   |   UIImageView:0x159d58c00
|   |   |   |   |   _UINavigationBarLargeTitleView:0x159d59880
|   |   |   |   |   |   UILabel:0x159d59dc0
|   |   |   |   |   •_UINavigationBarContentView:0x159d59260
|   |   |   |   |   |   *<UILayoutGuide: 0x2817ee060 - "BackButtonGuide(0x159d59720)", layoutFrame = {{0, 0}, {8, 44}}, owningView = <_UINavigationBarContentView: 0x159d59260; frame = (0 0; 375 44); layer = <CALayer: 0x282eaea60>>>
|   |   |   |   |   |   *<UILayoutGuide: 0x2817ee140 - "LeadingBarGuide(0x159d59720)", layoutFrame = {{8, 0}, {0, 44}}, owningView = <_UINavigationBarContentView: 0x159d59260; frame = (0 0; 375 44); layer = <CALayer: 0x282eaea60>>>
|   |   |   |   |   |   *<UILayoutGuide: 0x2817ee220 - "TitleView(0x159d59720)", layoutFrame = {{8, 0}, {359, 44}}, owningView = <_UINavigationBarContentView: 0x159d59260; frame = (0 0; 375 44); layer = <CALayer: 0x282eaea60>>>
|   |   |   |   |   |   *<UILayoutGuide: 0x2817ee300 - "TrailingBarGuide(0x159d59720)", layoutFrame = {{367, 0}, {0, 44}}, owningView = <_UINavigationBarContentView: 0x159d59260; frame = (0 0; 375 44); layer = <CALayer: 0x282eaea60>>>
|   |   |   |   |   |   *<UILayoutGuide: 0x2817ee3e0 - "UIViewLayoutMarginsGuide", layoutFrame = {{16, 0}, {343, 44}}, owningView = <_UINavigationBarContentView: 0x159d59260; frame = (0 0; 375 44); layer = <CALayer: 0x282eaea60>>>
|   |   |   |   |   |   *<UILayoutGuide: 0x2817e5ce0 - "UIViewSafeAreaLayoutGuide", layoutFrame = {{0, 0}, {375, 44}}, owningView = <_UINavigationBarContentView: 0x159d59260; frame = (0 0; 375 44); layer = <CALayer: 0x282eaea60>>>
|   |   |   |   |   |   *_UITAMICAdaptorView:0x15b50e7a0
|   |   |   |   |   |   |   DAT_Air_Vinyl.RecordViewNavigationBar:0x15b504370
|   |   |   |   |   |   |   |   UIImageView:0x15b50d430
|   |   |   |   |   |   |   |   DAT_Air_Vinyl.ScrollableTextView:0x15b50d660
|   |   |   |   |   |   |   |   |   UIScrollView:0x15c017200
|   |   |   |   |   |   |   |   |   |   DAT_Air_Vinyl.MainLabel:0x15b50d8c0'DAT-Air WSS (95B6DC)'
|   |   |   |   |   |   |   |   |   |   DAT_Air_Vinyl.MainLabel:0x15b50dbb0'DAT-Air WSS (95B6DC)'
|   |   |   |   |   |   |   |   UIButton:0x15b50dea0
|   |   |   |   |   |   |   |   |   UIImageView:0x159d773f0
|   |   |   |   |   _UINavigationBarModernPromptView:0x159d5a0b0
|   |   *UIView:0x159d369b0
|   |   |   *DAT_Air_Vinyl.MiniPlayerView:0x159d458c0
|   |   |   |   *<UILayoutGuide: 0x2817edb20 - "UIViewSafeAreaLayoutGuide", layoutFrame = {{0, 0}, {375, 1}}, owningView = <DAT_Air_Vinyl.MiniPlayerView: 0x159d458c0; frame = (0 0; 375 1); autoresize = W+H; gestureRecognizers = <NSArray: 0x2820829a0>; layer = <CALayer: 0x282eda960>>>
|   |   |   |   *UIImageView:0x159e0ec60
|   |   |   |   *DAT_Air_Vinyl.ScrollableTextView:0x159e10b20
|   |   |   |   |   UIScrollView:0x15a828200
|   |   |   |   |   |   DAT_Air_Vinyl.MainLabel:0x159e10f80
|   |   |   |   |   |   DAT_Air_Vinyl.MainLabel:0x159d482b0
|   |   |   |   *UIButton:0x159d44cf0
|   |   |   |   |   UIImageView:0x159d3ea10
|   |   |   |   *UIView:0x159d489a0
|   |   |   |   *UIView:0x159d48b80
|   |   *UITabBar:0x159d36b90
|   |   |   _UIBarBackground:0x159d3ec60
|   |   |   |   UIImageView:0x159d3f390
|   |   |   |   UIVisualEffectView:0x159d3f5c0
|   |   |   |   |   _UIVisualEffectBackdropView:0x159d47010
|   |   |   |   |   _UIVisualEffectSubview:0x159d3c420
|   |   |   |   |   _UIVisualEffectSubview:0x159d3da80
|   |   |   UITabBarButton:0x159d404b0
|   |   |   |   UITabBarSwappableImageView:0x159d33330
|   |   |   |   UITabBarButtonLabel:0x159d407d0'Library'
|   |   |   UITabBarButton:0x159d414f0
|   |   |   |   UITabBarSwappableImageView:0x159d41d10
|   |   |   |   UITabBarButtonLabel:0x159d419f0'Record'
|   |   |   UITabBarButton:0x159d42840
|   |   |   |   UITabBarSwappableImageView:0x159d43060
|   |   |   |   UITabBarButtonLabel:0x159d42d40'Exports'
|   |   |   UITabBarButton:0x159d43b90
|   |   |   |   UITabBarSwappableImageView:0x159d443b0
|   |   |   |   UITabBarButtonLabel:0x159d44090'Settings'
|   +UITransitionView:0x15b1084e0- AMBIGUOUS LAYOUT for UITransitionView:0x15b1084e0.minX{id: 1503}, UITransitionView:0x15b1084e0.minY{id: 1480}, UITransitionView:0x15b1084e0.Width{id: 1608}, UITransitionView:0x15b1084e0.Height{id: 1481}
|   |   UIView:0x15b519280
|   |   *_UIKeyboardLayoutAlignmentView:0x15b518e50- AMBIGUOUS LAYOUT for _UIKeyboardLayoutAlignmentView:0x15b518e50.minY{id: 1478}
|   |   *_UIAlertControllerView:0x15d815e00- AMBIGUOUS LAYOUT for _UIAlertControllerView:0x15d815e00.minX{id: 1609}, _UIAlertControllerView:0x15d815e00.minY{id: 1610}, _UIAlertControllerView:0x15d815e00.Width{id: 1611}, _UIAlertControllerView:0x15d815e00.Height{id: 1612}
|   |   |   *UIView:0x15b103200- AMBIGUOUS LAYOUT for UIView:0x15b103200.minX{id: 1582}, UIView:0x15b103200.minY{id: 1601}
|   |   |   |   *_UIAlertControllerInterfaceActionGroupView:0x15b510760- AMBIGUOUS LAYOUT for _UIAlertControllerInterfaceActionGroupView:0x15b510760.minX{id: 1522}
|   |   |   |   |   *<_UIContentConstraintsLayoutGuide: 0x15b510c40 - "", layoutFrame = {{0, 0}, {39, 171.66666666666666}}, owningView = <_UIAlertControllerInterfaceActionGroupView: 0x15b510760; frame = (0 0; 0 0); opaque = NO; gestureRecognizers = <NSArray: 0x282061bf0>; layer = <CALayer: 0x282e8dde0>>>
|   |   |   |   |   *UIView:0x15b510fb0
|   |   |   |   |   |   *_UIInterfaceActionGroupHeaderScrollView:0x15c035000
|   |   |   |   |   |   |   *<_UIScrollViewContentOffsetGuide: 0x2817e6140 - "UIScrollView-contentOffsetLayoutGuide", layoutFrame = {{0, 0}, {0, 0}}, owningView = <_UIInterfaceActionGroupHeaderScrollView: 0x15c035000; frame = (0 0; 0 0); clipsToBounds = YES; gestureRecognizers = <NSArray: 0x282060ab0>; layer = <CALayer: 0x282ea68c0>; contentOffset: {0, 0}; contentSize: {0, 0}; adjustedContentInset: {0, 0, 0, 0}>>
|   |   |   |   |   |   |   *UIView:0x15b515c10
|   |   |   |   |   |   |   |   *UIView:0x15b515df0- AMBIGUOUS LAYOUT for UIView:0x15b515df0.minX{id: 1580}, UIView:0x15b515df0.minY{id: 1812}, UIView:0x15b515df0.Height{id: 1813}
|   |   |   |   |   |   |   |   *UIView:0x15b515fd0- AMBIGUOUS LAYOUT for UIView:0x15b515fd0.minX{id: 1589}, UIView:0x15b515fd0.minY{id: 1814}, UIView:0x15b515fd0.Width{id: 1588}, UIView:0x15b515fd0.Height{id: 1815}
|   |   |   |   |   |   |   |   *UIView:0x15b5161b0- AMBIGUOUS LAYOUT for UIView:0x15b5161b0.minX{id: 1599}, UIView:0x15b5161b0.minY{id: 1816}
|   |   |   |   |   |   *groupView.actionsSequence...:0x15c032c00
|   |   |   |   |   |   |   +actions-separatableSequen...:0x15b511550
|   |   |   |   |   |   |   |   •actions-separatableSequen...:0x15b511970
|   |   |   |   |   |   |   |   |   *_UIInterfaceActionCustomViewRepresentationView:0x15b10cc30- AMBIGUOUS LAYOUT for _UIInterfaceActionCustomViewRepresentationView:0x15b10cc30.Height{id: 1650}
|   |   |   |   |   |   |   |   |   |   +_UIAlertControllerActionView:0x15b516e90
|   |   |   |   |   |   |   |   |   |   |   *UIView:0x15b517370
|   |   |   |   |   |   |   |   |   |   |   |   *UILabel:0x15b517550'Show devices'
|   |   |   |   |   |   |   |   |   *_UIInterfaceActionItemSeparatorView_iOS:0x15b60c530- AMBIGUOUS LAYOUT for _UIInterfaceActionItemSeparatorView_iOS:0x15b60c530.minY{id: 1725}
|   |   |   |   |   |   |   |   |   |   UIView:0x15b60c930
|   |   |   |   |   |   |   |   |   |   UIView:0x15b60cb10
|   |   |   |   |   |   |   |   |   *_UIInterfaceActionCustomViewRepresentationView:0x15b60bda0- AMBIGUOUS LAYOUT for _UIInterfaceActionCustomViewRepresentationView:0x15b60bda0.minY{id: 1727}, _UIInterfaceActionCustomViewRepresentationView:0x15b60bda0.Height{id: 1700}
|   |   |   |   |   |   |   |   |   |   +_UIAlertControllerActionView:0x15b517840
|   |   |   |   |   |   |   |   |   |   |   *UIView:0x15b517b20
|   |   |   |   |   |   |   |   |   |   |   |   *UILabel:0x15b517d00'Add device'
|   |   |   |   |   |   |   |   |   *_UIInterfaceActionItemSeparatorView_iOS:0x15b60d3c0- AMBIGUOUS LAYOUT for _UIInterfaceActionItemSeparatorView_iOS:0x15b60d3c0.minY{id: 1729}
|   |   |   |   |   |   |   |   |   |   UIView:0x15b60d5c0
|   |   |   |   |   |   |   |   |   |   UIView:0x15b60d7a0
|   |   |   |   |   |   |   |   |   *_UIInterfaceActionCustomViewRepresentationView:0x15b60bfe0- AMBIGUOUS LAYOUT for _UIInterfaceActionCustomViewRepresentationView:0x15b60bfe0.minY{id: 1723}, _UIInterfaceActionCustomViewRepresentationView:0x15b60bfe0.Height{id: 1653}
|   |   |   |   |   |   |   |   |   |   +_UIAlertControllerActionView:0x15b517ff0
|   |   |   |   |   |   |   |   |   |   |   *UIView:0x15b5182d0
|   |   |   |   |   |   |   |   |   |   |   |   *UILabel:0x15b5184b0'Cancel'
|   |   |   |   |   *_UIDimmingKnockoutBackdropView:0x15b512570
|   |   |   |   |   |   UIView:0x15b513340
|   |   |   |   |   |   UIVisualEffectView:0x15b512970
|   |   |   |   |   |   |   _UIVisualEffectBackdropView:0x15b512f30
|   |   |   |   |   |   |   _UIVisualEffectSubview:0x15b513140

制約の問題はiPhoneXでのみ発生するようです。iPadとiPhone7および7plusでは問題は発生しません。

ありがとうございました。

キム・スンボム

iPadでも同様の問題が発生しました。

sourceRectを削除し、view.frameをCGRect(x、y、0、0)に変更する問題を修正しました。

では、moreActionsCellSheetController.popoverPresentationController?.sourceRectコードを削除するのどうですか?

sourceRectは、UIAlertControllerの位置を意味します。ですから、CGRectのように設定したほうがいいと思います。

ありがとう。

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

Ambiguous reference to member '=='

分類Dev

Ambiguous reference to member '=='

分類Dev

Example of ambiguous DateTimeOffset

分類Dev

Ambiguous use of 'observeSingleEvent(of: with:)

分類Dev

Why following call is ambiguous?

分類Dev

Use of overloaded operator ambiguous

分類Dev

Ambiguous implicit values for Typeclass

分類Dev

Resolving an ambiguous type variable

分類Dev

Is this context free grammar ambiguous?

分類Dev

inheriatance problems "ambiguous request"

分類Dev

Given grammar ambiguous or not?

分類Dev

Nested array - ambiguous

分類Dev

Multiple inheritance ambiguous base class

分類Dev

ambiguous use of selector dataTask(with: completionHandler:)

分類Dev

Ambiguous use of init in Swift 2.2

分類Dev

error: call of overloaded distance is ambiguous

分類Dev

Declaring resolution to ambiguous constructor reference

分類Dev

Ambiguous Entry System.Reflection

分類Dev

Ambiguous function call in C++

分類Dev

rails passing in id parameter ambiguous

分類Dev

Google sign in ambiguous reference to member 'subscript'

分類Dev

Ambiguous partial specialization depending on std::enable_if

分類Dev

Swift Error: ambiguous reference to member 'jsonObject(with:options:)

分類Dev

PostgreSQL - Function with local variables - Column reference is ambiguous

分類Dev

<column> is ambiguous in column comparison between two tables

分類Dev

Ambiguous mapping methods found for mapping property

分類Dev

Converting to Swift 4, ambiguous subscript error

分類Dev

recursive view using lookup tables with ambiguous joins

分類Dev

c++ const mysqlpp::String ambiguous error

Related 関連記事

ホットタグ

アーカイブ