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)
}
}
Post
Replies
Boosts
Views
Activity
I was a middleware programmer for a company and a junior one at that. I wrote 95% of my middleware with c#. They did have me do some IOS/Android for them and I used Xamarin just after it came out...this was about 2014 I believe. Fast forward to 2022 and I am not just discovering Swift as well as I have Visual Studio 2022 and I see Xamarin is now native to that IDE since Microsoft owns that platform now.
I just wanted to poll the forum and get a feel for what language do you develop your IOS code with mainly and why?
I am of course very familiar with c#/.net but my first look at Swift it looks pretty cool! (except I keep trying to put in a ; after a line of code out of habit lol).
I appreciate your time, advise and opinions.