geometryreader

SwiftUI iOS14 GeometryReader Invalid frame dimension

余生长醉 提交于 2020-12-13 18:56:17
问题 My GeometryReader was working fine in iOS13 but now in iOS14 i get a thread issue. "Invalid frame dimension (negative or non-finite)." I printed the size that the reader should give back and it looked fine. The app is still basically working, but looks a bit weird, because there is some padding introduced. Does anyone have any ideas how to tackle this? 来源: https://stackoverflow.com/questions/64027041/swiftui-ios14-geometryreader-invalid-frame-dimension

SwiftUI iOS14 GeometryReader Invalid frame dimension

这一生的挚爱 提交于 2020-12-13 18:55:21
问题 My GeometryReader was working fine in iOS13 but now in iOS14 i get a thread issue. "Invalid frame dimension (negative or non-finite)." I printed the size that the reader should give back and it looked fine. The app is still basically working, but looks a bit weird, because there is some padding introduced. Does anyone have any ideas how to tackle this? 来源: https://stackoverflow.com/questions/64027041/swiftui-ios14-geometryreader-invalid-frame-dimension

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

How do I correctly pass a “cell item” to a .sheet from a SwiftUI LazyVGrid?

浪子不回头ぞ 提交于 2020-11-25 03:40:33
问题 Here is my example, and I can't tell if this is a bug or not. All my cells load correctly, but when I try to bring up the DetailView() as a sheet, the item pased in is always whatevr item is shown first in the grid (in the top left in my case here), NOT the "cell" that was tapped. So, why is the item from ForEach loop correctly populating the cells, but not being passed to the .sheet via the button? import SwiftUI let columnCount: Int = 11 let gridSpacing: CGFloat = 1 struct GridView: View {

SwiftUI GeometryReader does not layout custom subviews in center

两盒软妹~` 提交于 2020-07-30 06:09:38
问题 I have a custom view: struct ImageContent: View { var body: some View { Image("smile") .resizable() .scaledToFit() } } Which is being placed into another view with a GeometryReader : var body: some View { GeometryReader { geometry in ImageContent() //Image("smile").resizable().scaledToFit() } } The problem is, the ImageContent view is not centered on the screen, it is being placed on the top, however, by removing the ImageContent subview and directly adding the view's content into the

ForEach and GeometryReader: variable height for children?

只谈情不闲聊 提交于 2020-06-17 08:05:49
问题 I have following example: import SwiftUI struct TestSO: View { @State var cards = [ Card(title: "short title text", subtitle: "short title example"), Card(title: "medium title text text text text text", subtitle: "medium title example"), Card(title: "long title text text text text text text text text text text text text text text text text text", subtitle: "long title example"), Card(title: "medium title text text text text text", subtitle: "medium title example"), Card(title: "short title

How do I get my UIView to correctly size for its content in SwiftUI?

十年热恋 提交于 2020-05-17 02:57:13
问题 I want to use the awesome MultiSegmentPicker written by Yonat Sharon in my SwiftUI View. https://github.com/yonat/MultiSelectSegmentedControl However, I don't fully understand the interaction between the UIViewRepresentable View and my SwiftUI View. How do I get the host view controller to shrink its height down to the size of the segmented control? Here's the debugger view of the demo page - notice the blue area around the top bar: The demo code doesn't give a lot of insight into the issue,

How to use GeometryReader without it filling the View

喜你入骨 提交于 2020-02-23 04:20:28
问题 This is the layout I'm aiming for. import SwiftUI import PlaygroundSupport struct TestView: View { let text: String var body: some View { Text(self.text) } } struct ContentView: View { var body: some View { ZStack { TestView(text: "bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla") .frame(width: 250) .background(Color.red) } } } PlaygroundPage.current.setLiveView(ContentView()) But I also want to use the GeometryReader and when I

How to use GeometryReader without it filling the View

淺唱寂寞╮ 提交于 2020-02-23 04:20:06
问题 This is the layout I'm aiming for. import SwiftUI import PlaygroundSupport struct TestView: View { let text: String var body: some View { Text(self.text) } } struct ContentView: View { var body: some View { ZStack { TestView(text: "bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla") .frame(width: 250) .background(Color.red) } } } PlaygroundPage.current.setLiveView(ContentView()) But I also want to use the GeometryReader and when I