I have an issue with some test code, where I can't drag objects to the canvas nor does clicking on it do anything....it is as if the canvas is read only....
I have narrowed this down to the code that is suggested to be put in due to a depreciated bit of code in IOS 15 and later...
instead of this:
.alert(isPresented: $alertIsVisible, content: {
return Alert(title: Text("Hello there!"), message: Text("This is my first pop-up"), dismissButton: .default(Text("Awesome!")))
})
The newer IOS 15 code that is suggested is this:
.alert("Hello There!!", isPresented: $alertIsVisible) { Button("Awesome!") {}
} message: {
Text("This is my first popup")
}
Both work, both compile… but with the newer code, I then can’t drag and drop any more object from the library to the canvas…it is like the canvas becomes read only… Please advise
full test code below:
// ContentView.swift
// Bullseye
//
// Created by Chuck Condron on 12/1/22.
//
import SwiftUI
struct ContentView: View {
@State private var alertIsVisible: Bool = false
var body: some View {
VStack {
Text("🎯🎯🎯\nPUT THE BULLSEYE AS CLOSE AS YOU CAN TO THE TOP")
.bold()
.kerning(2.0)
.multilineTextAlignment(.center)
.lineSpacing(4.0)
.font(.footnote)
Text("89")
.kerning(-1.0)
.font(.largeTitle)
.fontWeight(.black)
HStack {
Text("1")
.bold()
Slider(value: .constant(50), in: 1.0...100.0)
Text("100")
.bold()
}
Button(action: {
self.alertIsVisible = true
}) {
Text("Hit me")
}
//new code for IOS 15 and above
.alert("Hello There!!",
isPresented:
$alertIsVisible) {
Button("Awesome!") {}
} message: {
Text("This is my first popup")
}
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
ContentView()
//.previewLayout(.fixed(width: 568, height: 320))
.previewInterfaceOrientation(.landscapeLeft)
}
}