6

I'm toying around with an image display within SwiftUI and decided to attach an Alert to activate if an image can't be found.

The following is the abridge code:

struct ContentView: View {
    ...
    @State var image: URLImage = URLImage()
    ...
    @State var showActionSheet = true

    var body: some View {
        ZStack {
            Color.green
            NavigationView {
                VStack {
                    Button(action: {
                        self.url = "https://xxxx.org/\(Int.random(in: 0 ..< 10)).png"
                        self.image.imageLoader.load(url: URL(string: self.url)!)
                    }) {
                        Text("Get Random Image")
                    }
                    image.actionSheet(isPresented: $showActionSheet) {
                        ActionSheet(title: Text("Action Time"), message: Text("Greetings Ric!"), buttons:
                            [.default(Text("First Button"), action: {
                                print("First Button")
                        })])
                    }
                }.navigationBarTitle(Text("Ric's Images"))
            }
        }
    }
}

When I set the 'showAlertSheet' flag to 'true', I get the alert but also the compiler's constraint complaint:

2019-11-25 12:41:21.628064-0800 GetImages[32413:1078621] [LayoutConstraints] Unable to simultaneously satisfy constraints. Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. ( "" )

Will attempt to recover by breaking constraint

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger. The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in may also be helpful.

enter image description here

The constraints are auto-generated.
How do I solve this?

Frederick C. Lee
  • 9,019
  • 17
  • 64
  • 105
  • 4
    It is an internal issue. Don't worry about it. – Mojtaba Hosseini Nov 25 '19 at 21:20
  • What is your URLImage? Have you tried just attach action sheet to another view, say to button or VStack, in fact it should not matter, but might be the reason is that URLImage is state? – Asperi Nov 26 '19 at 07:20
  • 1
    No... just the action sheet. I don't have a problem with an action alert vs sheet. I'm assuming this in an Apple matter, being this is new technology. – Frederick C. Lee Nov 26 '19 at 21:27

0 Answers0