Post

Replies

Boosts

Views

Activity

Reply to Unable to present. Please file a bug.
Definitely something wrong with SwiftUI. Here is a simple example that shows "Unable to present. Please file a bug." on iOS, and does not work on Mac Catalyst. struct ContentView: View { @State var arr = ["1","2","3"] var body: some View { NavigationView { ScrollView { ForEach(arr, id: \.self) { name in NavigationLink(destination: Text("view \(name)")) { Text("to view \(name)").padding(5) } } } } } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
May ’21
Reply to Unable to present. Please file a bug.
@bob_mosh, @shitingsand, your issues may not be related to the original NavigationLink problem. Show us some example code, maybe we can track down your particular issues. In my example I tried all sorts of things, @State, @StateObjects, @ObservedObject, var, etc.. without any impact.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
May ’21
Reply to TextEditor Problem, or me?
try this: struct ContentView: View { @State var text = "start text" init() { UITextView.appearance().backgroundColor = .clear } var body: some View { NavigationView { ZStack { Color.green.ignoresSafeArea() TextEditor(text: $text) } .navigationTitle("Notepad Test!") } } } or this, if you only want the text editor background color: struct ContentView: View { @State var text = "start text" var body: some View { NavigationView { TextEditor(text: $text).padding().colorMultiply(.green) .navigationTitle("Notepad Test!") } } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
May ’21
Reply to Unable to present. Please file a bug.
yes it works with List, however even without ScrollView the message still shows, but it works on iPhone. On Mac Catalyst, if I include StackNavigationViewStyle it shows the "error" but it works, whereas without it it doesn't work at all. I'm now on macos 11.4 beta2, target ios 14.5, testing on ios 14.6 iPhone. struct ContentView: View { var body: some View { NavigationView { VStack { NavigationLink(destination: Text("view 1")) { VStack{ Text("to view 1").padding(5) } } NavigationLink(destination: Text("view 2")) { VStack{ Text("to view 2").padding(5) } } NavigationLink(destination: Text("view 3")) { VStack{ Text("to view 3").padding(5) } } } }.navigationViewStyle(StackNavigationViewStyle()) // } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
May ’21
Reply to SwiftUI Alert in Previews is not shown
This is the full code I used on macos 11.4, xcode 12.5, target ios 14.5 and macCatalyst. Is this not working for you? import SwiftUI @main struct TestApp: App { var body: some Scene { WindowGroup { ContentView() } } } struct ContentView: View { var body: some View { Alerts() } } struct Alerts: View { var body: some View { NavigationView { Text("Where is the Alert?") .alert(isPresented: .constant(true)) { Alert(title: Text("Hello"), message: Text("World")) } } } } struct Alerts_Previews: PreviewProvider { static var previews: some View { Alerts() } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
May ’21
Reply to Not append new data in an array
what you are doing is resetting the "cart" to empty each time you call "Shop". Note, passing variables and etc... to another View is an important concept to master. Try this: struct ContentView: View { @ObservedObject var cart = Products() var body: some View { NavigationView { List { ForEach(cart.products) { product in Text("\(product.name) \(product.price)$") } } .navigationBarItems( trailing: NavigationLink(destination: Shop(cart: cart)) { // Text("Go Shop") }) .navigationBarTitle("Cart") }.navigationViewStyle(StackNavigationViewStyle()) } } struct Shop: View { @ObservedObject var cart:Products // var body: some View { VStack{ Button("Add Product To Cart") { cart.addProduct(product: Product(name: "Name", price: 399)) } } } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
May ’21
Reply to How to reverse the bounds parameter of a slider
You cannot "reverse" the bounds. You will have to use some very basic math to calculate the desired value. According to the docs, Slider takes a ClosedRange for the "in" parameter, and a ClosedRange is (https://docs.swift.org/swift-book/LanguageGuide/BasicOperators.html): "The closed range operator (a...b) defines a range that runs from a to b, and includes the values a and b. The value of a must not be greater than b."
Topic: UI Frameworks SubTopic: SwiftUI Tags:
May ’21
Reply to Anyone have a pointer about a crash Exception Type: EXC_BAD_ACCESS (SIGSEGV) Exception Subtype: KERN_INVALID_ADDRESS at 0x0000000000000010
just an observation, I would avoid the "!" in: selectedPenaltyLength = formatSeconds(gameState.penaltyLengths![0]) and use: init(gameState : GameState) { self.gameState = gameState selectedPenaltyLength = "" selectedPenaltyIndex = 0 separatePenaltyClock = false if let penalties = gameState.penaltyLengths, penalties.count 0 { selectedPenaltyLength = formatSeconds(penalties[0]) } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
May ’21
Reply to Unable to present. Please file a bug.
to track down the error, please show a reproducible example, in particular all your code related to "AddictionListViewModel" and "AddictionCellView"
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
May ’21
Reply to Unable to present. Please file a bug.
Definitely something wrong with SwiftUI. Here is a simple example that shows "Unable to present. Please file a bug." on iOS, and does not work on Mac Catalyst. struct ContentView: View { @State var arr = ["1","2","3"] var body: some View { NavigationView { ScrollView { ForEach(arr, id: \.self) { name in NavigationLink(destination: Text("view \(name)")) { Text("to view \(name)").padding(5) } } } } } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
May ’21
Reply to Unable to present. Please file a bug.
@bob_mosh, @shitingsand, your issues may not be related to the original NavigationLink problem. Show us some example code, maybe we can track down your particular issues. In my example I tried all sorts of things, @State, @StateObjects, @ObservedObject, var, etc.. without any impact.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
May ’21
Reply to TextEditor Problem, or me?
try this: struct ContentView: View { @State var text = "start text" init() { UITextView.appearance().backgroundColor = .clear } var body: some View { NavigationView { ZStack { Color.green.ignoresSafeArea() TextEditor(text: $text) } .navigationTitle("Notepad Test!") } } } or this, if you only want the text editor background color: struct ContentView: View { @State var text = "start text" var body: some View { NavigationView { TextEditor(text: $text).padding().colorMultiply(.green) .navigationTitle("Notepad Test!") } } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
May ’21
Reply to Unable to present. Please file a bug.
yes it works with List, however even without ScrollView the message still shows, but it works on iPhone. On Mac Catalyst, if I include StackNavigationViewStyle it shows the "error" but it works, whereas without it it doesn't work at all. I'm now on macos 11.4 beta2, target ios 14.5, testing on ios 14.6 iPhone. struct ContentView: View { var body: some View { NavigationView { VStack { NavigationLink(destination: Text("view 1")) { VStack{ Text("to view 1").padding(5) } } NavigationLink(destination: Text("view 2")) { VStack{ Text("to view 2").padding(5) } } NavigationLink(destination: Text("view 3")) { VStack{ Text("to view 3").padding(5) } } } }.navigationViewStyle(StackNavigationViewStyle()) // } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
May ’21
Reply to Problem with alert in iOS4.5
seems the Alert is trying to render before the View is fully setup, try this: .onAppear { // showingAlert = true }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
May ’21
Reply to Problem with alert in iOS4.5
If you are trying to display an alert on screen transition, then you could try this as a workaround until it is fixed properly: }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
May ’21
Reply to Popover does not appear when closed during variable edit
tried your code and all is working well for me on macos 11.4 beta, target ios 14.5 and Mac Catalyst and macos 11.3, using Xcode 12.5. You could try: Popover().frame(width: 222, height: 222).background(Color.green) to make sure you can see the Popover. What system are you using/targeting?
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
May ’21
Reply to SwiftUI: How to size a popover to content with a Form on iOS 14.5
you may have to control the size yourself. Something like this: var body: some View { GeometryReader { geom in ... .popover(isPresented: $showPersonEditor) { PersonEditor(chosenPerson: $chosenPerson) .environmentObject(document) .frame(width: geom.size.width/2, height: geom.size.height/2) } ... } ...
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
May ’21
Reply to SwiftUI: How to insert custom Commands inside .pasteboard CommandGroup
There is a "before" and "after" parameter that could be used, such as: @main struct TestApp: App { var body: some Scene { WindowGroup { ContentView() }.commands { CommandGroup(after: .pasteboard) { // in Edit Button(action: { // do something }) { Text("My_Menu_Item") } } } } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
May ’21
Reply to SwiftUI Alert in Previews is not shown
you need a "NavigationView" for the "Alert" to show, for example: struct Alerts: View { var body: some View { NavigationView { // Text("Where is the Alert?") .alert(isPresented: .constant(true)) { Alert(title: Text("Hello"), message: Text("World")) } } } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
May ’21
Reply to SwiftUI Alert in Previews is not shown
This is the full code I used on macos 11.4, xcode 12.5, target ios 14.5 and macCatalyst. Is this not working for you? import SwiftUI @main struct TestApp: App { var body: some Scene { WindowGroup { ContentView() } } } struct ContentView: View { var body: some View { Alerts() } } struct Alerts: View { var body: some View { NavigationView { Text("Where is the Alert?") .alert(isPresented: .constant(true)) { Alert(title: Text("Hello"), message: Text("World")) } } } } struct Alerts_Previews: PreviewProvider { static var previews: some View { Alerts() } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
May ’21
Reply to Not append new data in an array
what you are doing is resetting the "cart" to empty each time you call "Shop". Note, passing variables and etc... to another View is an important concept to master. Try this: struct ContentView: View { @ObservedObject var cart = Products() var body: some View { NavigationView { List { ForEach(cart.products) { product in Text("\(product.name) \(product.price)$") } } .navigationBarItems( trailing: NavigationLink(destination: Shop(cart: cart)) { // Text("Go Shop") }) .navigationBarTitle("Cart") }.navigationViewStyle(StackNavigationViewStyle()) } } struct Shop: View { @ObservedObject var cart:Products // var body: some View { VStack{ Button("Add Product To Cart") { cart.addProduct(product: Product(name: "Name", price: 399)) } } } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
May ’21
Reply to How to reverse the bounds parameter of a slider
You cannot "reverse" the bounds. You will have to use some very basic math to calculate the desired value. According to the docs, Slider takes a ClosedRange for the "in" parameter, and a ClosedRange is (https://docs.swift.org/swift-book/LanguageGuide/BasicOperators.html): "The closed range operator (a...b) defines a range that runs from a to b, and includes the values a and b. The value of a must not be greater than b."
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
May ’21
Reply to Anyone have a pointer about a crash Exception Type: EXC_BAD_ACCESS (SIGSEGV) Exception Subtype: KERN_INVALID_ADDRESS at 0x0000000000000010
just an observation, I would avoid the "!" in: selectedPenaltyLength = formatSeconds(gameState.penaltyLengths![0]) and use: init(gameState : GameState) { self.gameState = gameState selectedPenaltyLength = "" selectedPenaltyIndex = 0 separatePenaltyClock = false if let penalties = gameState.penaltyLengths, penalties.count 0 { selectedPenaltyLength = formatSeconds(penalties[0]) } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
May ’21