swiftui

typealias LazyVStack for iOS 13

半腔热情 提交于 2020-11-29 10:13:37
问题 I have a SwiftUI app that I want to maintain iOS 13 support for, but on iOS 14 I want to use the new LazyVStack and LazyHStack . I was thinking typealias would be perfect for this, but wasn't sure how to properly set this up so the alias is used on iOS 13 but not on 14. I tried this, but believe this would make the alias available on iOS 13 and up, so would include it on iOS 14 too. Is there a way to set the availability to iOS 13 only? Or is there a better way to do this? @available(iOS 13.0

typealias LazyVStack for iOS 13

荒凉一梦 提交于 2020-11-29 10:12:44
问题 I have a SwiftUI app that I want to maintain iOS 13 support for, but on iOS 14 I want to use the new LazyVStack and LazyHStack . I was thinking typealias would be perfect for this, but wasn't sure how to properly set this up so the alias is used on iOS 13 but not on 14. I tried this, but believe this would make the alias available on iOS 13 and up, so would include it on iOS 14 too. Is there a way to set the availability to iOS 13 only? Or is there a better way to do this? @available(iOS 13.0

TabView with “PageTabViewStyle” does not update it's content when @State var changes

无人久伴 提交于 2020-11-29 09:04:26
问题 I came across a weird Issue in SwiftUI. I created a simple View that only holds a Button and a TabView that uses the PageViewStyle. It seems that the TabView does not update it's content correctly depending on the State of the Variable. It seems that the content gets updated somehow but the View wont be updated how I would expect Here is the Code of my View: struct ContentView: View { @State var numberOfPages: Int = 0 @State var selectedIndex = 0 var body: some View { VStack { Text("Tap Me")

TabView with “PageTabViewStyle” does not update it's content when @State var changes

纵然是瞬间 提交于 2020-11-29 09:02:52
问题 I came across a weird Issue in SwiftUI. I created a simple View that only holds a Button and a TabView that uses the PageViewStyle. It seems that the TabView does not update it's content correctly depending on the State of the Variable. It seems that the content gets updated somehow but the View wont be updated how I would expect Here is the Code of my View: struct ContentView: View { @State var numberOfPages: Int = 0 @State var selectedIndex = 0 var body: some View { VStack { Text("Tap Me")

SwiftUI - nested list

╄→гoц情女王★ 提交于 2020-11-29 08:17:30
问题 I'm trying to create a nested hierarchical list, so that for each task I can have subtasks like in iOS reminders app: First attempt was to embed another list inside a list cell. import SwiftUI struct SwiftUIView: View { var body: some View { List { List { Text("Hello, World!") } } } } struct SwiftUIView_Previews: PreviewProvider { static var previews: some View { SwiftUIView() } But, didn't work out... Anyone can help? cheers 回答1: Why do you think it should be List in List... Such visual

SwiftUI - nested list

社会主义新天地 提交于 2020-11-29 08:14:45
问题 I'm trying to create a nested hierarchical list, so that for each task I can have subtasks like in iOS reminders app: First attempt was to embed another list inside a list cell. import SwiftUI struct SwiftUIView: View { var body: some View { List { List { Text("Hello, World!") } } } } struct SwiftUIView_Previews: PreviewProvider { static var previews: some View { SwiftUIView() } But, didn't work out... Anyone can help? cheers 回答1: Why do you think it should be List in List... Such visual

SwiftUI - nested list

偶尔善良 提交于 2020-11-29 08:14:32
问题 I'm trying to create a nested hierarchical list, so that for each task I can have subtasks like in iOS reminders app: First attempt was to embed another list inside a list cell. import SwiftUI struct SwiftUIView: View { var body: some View { List { List { Text("Hello, World!") } } } } struct SwiftUIView_Previews: PreviewProvider { static var previews: some View { SwiftUIView() } But, didn't work out... Anyone can help? cheers 回答1: Why do you think it should be List in List... Such visual

How to access NSWindow from @main App using only SwiftUI?

人盡茶涼 提交于 2020-11-29 02:50:43
问题 At this answer the solution work for Scene plus swiftUI. However using @main like: @main struct MyApp: App { @StateObject private var model = MyModel() var body: some Scene { WindowGroup { Router { AppContent() }.environmentObject(self.model) } } } I also tried to get the main window by using var window: NSWindow? { let window = NSApplication.shared.mainWindow return window } Nevertheless, the mainWindow always return nil Update: I need the NSWindow due to the need of conforming with

How to access NSWindow from @main App using only SwiftUI?

前提是你 提交于 2020-11-29 02:49:44
问题 At this answer the solution work for Scene plus swiftUI. However using @main like: @main struct MyApp: App { @StateObject private var model = MyModel() var body: some Scene { WindowGroup { Router { AppContent() }.environmentObject(self.model) } } } I also tried to get the main window by using var window: NSWindow? { let window = NSApplication.shared.mainWindow return window } Nevertheless, the mainWindow always return nil Update: I need the NSWindow due to the need of conforming with

How to access NSWindow from @main App using only SwiftUI?

杀马特。学长 韩版系。学妹 提交于 2020-11-29 02:49:33
问题 At this answer the solution work for Scene plus swiftUI. However using @main like: @main struct MyApp: App { @StateObject private var model = MyModel() var body: some Scene { WindowGroup { Router { AppContent() }.environmentObject(self.model) } } } I also tried to get the main window by using var window: NSWindow? { let window = NSApplication.shared.mainWindow return window } Nevertheless, the mainWindow always return nil Update: I need the NSWindow due to the need of conforming with