ios14

iOS 14 Invalid frame dimension (negative or non-finite)

牧云@^-^@ 提交于 2020-12-05 09:58:00
问题 My App uses GeometryReader with some padding to setup a View frame dimension inside a NavigationView. Since iOS 14 i get the following error message: Invalid frame dimension (negative or non-finite) Here is some example code to test: import SwiftUI struct ContentView: View { let padding:CGFloat = 16.0 var body: some View { NavigationView { GeometryReader { p in Text("Hello, world!") .frame(width: p.size.width - padding) .padding() } } } } struct ContentView_Previews: PreviewProvider { static

iOS 14 Invalid frame dimension (negative or non-finite)

强颜欢笑 提交于 2020-12-05 09:54:42
问题 My App uses GeometryReader with some padding to setup a View frame dimension inside a NavigationView. Since iOS 14 i get the following error message: Invalid frame dimension (negative or non-finite) Here is some example code to test: import SwiftUI struct ContentView: View { let padding:CGFloat = 16.0 var body: some View { NavigationView { GeometryReader { p in Text("Hello, world!") .frame(width: p.size.width - padding) .padding() } } } } struct ContentView_Previews: PreviewProvider { static

SwiftUI change output format of `Text` using as `.timer`

♀尐吖头ヾ 提交于 2020-12-04 08:42:57
问题 Is there a way to change the output format of a Text using init(_ date: Date, style: Text.DateStyle) ? Using a .timer , the output is like: 0:42 , but I want something like 00:00:42 . Background I want to create a widget (iOS 14) where a timer is running, and as I think it's not a good idea to trigger a widget update every second, and this may even also not work reliably, at least that's not how widget are indented to be used. So I thought about using this predefined timer functionality of

Selected list row's background remains grey (selected) after navigating back in List (SwiftUI). iOS14 + Xcode12

陌路散爱 提交于 2020-11-30 07:42:30
问题 The selected row remains grey after navigating back from the detail view. Happening both on simulator and real device, only on iOS 14. Does anyone know how to remove it so it behaves the same as on iOS 13 (doesn't remain selected)? This is the only code in the project. (No other navigation's or anything). let items = ["item1", "item2"] struct ContentView: View { var body: some View { NavigationView { VStack { Text("Hello") List(items, id: \.self) { item in NavigationLink(destination: Text

Selected list row's background remains grey (selected) after navigating back in List (SwiftUI). iOS14 + Xcode12

旧时模样 提交于 2020-11-30 07:36:47
问题 The selected row remains grey after navigating back from the detail view. Happening both on simulator and real device, only on iOS 14. Does anyone know how to remove it so it behaves the same as on iOS 13 (doesn't remain selected)? This is the only code in the project. (No other navigation's or anything). let items = ["item1", "item2"] struct ContentView: View { var body: some View { NavigationView { VStack { Text("Hello") List(items, id: \.self) { item in NavigationLink(destination: Text

Selected list row's background remains grey (selected) after navigating back in List (SwiftUI). iOS14 + Xcode12

十年热恋 提交于 2020-11-30 07:35:52
问题 The selected row remains grey after navigating back from the detail view. Happening both on simulator and real device, only on iOS 14. Does anyone know how to remove it so it behaves the same as on iOS 13 (doesn't remain selected)? This is the only code in the project. (No other navigation's or anything). let items = ["item1", "item2"] struct ContentView: View { var body: some View { NavigationView { VStack { Text("Hello") List(items, id: \.self) { item in NavigationLink(destination: Text

Clear background for form sections in SwiftUI?

雨燕双飞 提交于 2020-11-25 03:46:47
问题 I'm trying to remove the white background of some sections so the elements lay right on the grey background, but I can't get the section background to be removed or transparent. This is what I'm trying: struct ContentView: View { var body: some View { Form { Section { Text("Hello!") Button { print("Clicked") } label: { Text("Click Me!!") } } Section { VStack { Button("Button 1") {} Spacer() Button("Button 2") {} } } .background(Color.clear) // Not doing anything Section { VStack(alignment:

Clear background for form sections in SwiftUI?

筅森魡賤 提交于 2020-11-25 03:43:33
问题 I'm trying to remove the white background of some sections so the elements lay right on the grey background, but I can't get the section background to be removed or transparent. This is what I'm trying: struct ContentView: View { var body: some View { Form { Section { Text("Hello!") Button { print("Clicked") } label: { Text("Click Me!!") } } Section { VStack { Button("Button 1") {} Spacer() Button("Button 2") {} } } .background(Color.clear) // Not doing anything Section { VStack(alignment:

SwiftUI: What is @AppStorage property wrapper

吃可爱长大的小学妹 提交于 2020-11-24 17:33:47
问题 I used to save important App data like login credentials into UserDefaults using the following statement: UserDefaults.standard.set("sample@email.com", forKey: "emailAddress") Now, I have come to know SwiftUI has introduced new property wrapper called: @AppStorage Could anyone please explain how the new feature works? 回答1: @AppStorage is a convenient way to save and read variables from UserDefaults and use them in the same way as @State properties. It can be seen as a @State property which is

iPhone is not available. Please reconnect the device. / iOS 14.2 - Xcode 12.1

南笙酒味 提交于 2020-11-24 15:40:57
问题 I just updated my iPhone to iOS 14.2. When I want to launch an app on the device from Xcode, I now keep seing this: I also just updated Xcode to Version 12.1, hoping it would solve the problem, but it doesn't make any difference, I keep getting the same message. Obviously I tried disconnecting and reconnecting the device, but to no avail. I also removed all the data under ~/Library/Developer/Xcode/DerivedData/, but again with no effect. It seems like some other people have had this issue