swiftui

SwiftUI in iOS14 Keyboard Avoidance Issues and IgnoresSafeArea Modifier Issues

二次信任 提交于 2020-12-02 07:19:28
问题 iOS13 saw TextField not having any sort of keyboard avoidance handling in place. As such, we created our how keyboard avoidance mechanism which works well. We upgraded to iOS14 and this resulted in TextFields having keyboard avoidance built in. However, the keyboard avoidance does not seem to work as expected. Issue 1 The first issue we experienced was keyboard avoidance not working expected for TextFields in and around the centre of the screen. Given this code: struct ContentView: View {

SwiftUI in iOS14 Keyboard Avoidance Issues and IgnoresSafeArea Modifier Issues

孤街醉人 提交于 2020-12-02 07:19:10
问题 iOS13 saw TextField not having any sort of keyboard avoidance handling in place. As such, we created our how keyboard avoidance mechanism which works well. We upgraded to iOS14 and this resulted in TextFields having keyboard avoidance built in. However, the keyboard avoidance does not seem to work as expected. Issue 1 The first issue we experienced was keyboard avoidance not working expected for TextFields in and around the centre of the screen. Given this code: struct ContentView: View {

UIDocumentPickerViewController doesn't show any contents on Mac Catalyst

淺唱寂寞╮ 提交于 2020-12-01 12:23:06
问题 UIDocumentPickerViewController works on iOS but not on Mac Catalyst. Is there any alternatives to workaround this issue? BTW, NSOpenPanel is unavailable on Mac Catalyst. 回答1: There's extra code in @UnchartedWorks' excellent answer. Here's a cleaner version with some options, more copy/paste-able into your code. This works on iOS, iPadOS, and Mac Catalyst (without using a #if conditional). import Foundation import SwiftUI import MobileCoreServices /// A wrapper for a

UIDocumentPickerViewController doesn't show any contents on Mac Catalyst

拈花ヽ惹草 提交于 2020-12-01 12:11:22
问题 UIDocumentPickerViewController works on iOS but not on Mac Catalyst. Is there any alternatives to workaround this issue? BTW, NSOpenPanel is unavailable on Mac Catalyst. 回答1: There's extra code in @UnchartedWorks' excellent answer. Here's a cleaner version with some options, more copy/paste-able into your code. This works on iOS, iPadOS, and Mac Catalyst (without using a #if conditional). import Foundation import SwiftUI import MobileCoreServices /// A wrapper for a

How to fill TextField with data from Core Data and update changes?

江枫思渺然 提交于 2020-12-01 12:00:45
问题 I am trying to learn how to Save, Edit and Delete data using Core Data. So far, with the help of this great community, I have managed to Save and Delete, but I don't know how to Edit and Update currently saved data. Here is a simple example of an app I am working on. It is a list with items from Core Data. I am adding new list entries on a modal (AddItemView) and deleting them on EditItemView. I would like to edit and update data as well on the AddItemView view. I managed to pass data to hint

How to automatically reflect CoreData+iCloud Changes in SwiftUI view?

荒凉一梦 提交于 2020-12-01 11:19:26
问题 🤓 So ...I have an app with StoreData and iCloud enabled. My data is syncing between the devices but I don't ge the behaviour I want when it comes to reflecting the changes in the UI. The behaviour I want: When a user has my app open on two devices (A & B) and makes a change one one (A) of them I want the change to automatically reflect in the second (B) device UI within some reasonable time. The behaviour I currently have: When the user makes changes on one device (A) nothing ever happens on

iOS 14 Widgets + SwiftUI + Firebase?

空扰寡人 提交于 2020-12-01 10:42:10
问题 I'm still pretty new to SwiftUI and Firebase. Recently, as a hobby, I have been developing an app for my school. After the launch of Xcode 12, I decided to experiment with the new features such as Widgets. However, since my app gets its data from Firebase, I've been having some problems. My most recent problem is this "Thread 1: "Failed to get FirebaseApp instance. Please call FirebaseApp.configure() before using Firestore". I'm not entirely sure where to put "FirebaseApp.configure()" as

iOS 14 Widgets + SwiftUI + Firebase?

一笑奈何 提交于 2020-12-01 10:42:08
问题 I'm still pretty new to SwiftUI and Firebase. Recently, as a hobby, I have been developing an app for my school. After the launch of Xcode 12, I decided to experiment with the new features such as Widgets. However, since my app gets its data from Firebase, I've been having some problems. My most recent problem is this "Thread 1: "Failed to get FirebaseApp instance. Please call FirebaseApp.configure() before using Firestore". I'm not entirely sure where to put "FirebaseApp.configure()" as

SwiftUI - Using GeometryReader Without Modifying The View Size

。_饼干妹妹 提交于 2020-12-01 09:36:30
问题 I have a header view which extends its background to be under the status bar using edgesIgnoringSafeArea . To align the content/subviews of the header view correctly, I need the safeAreaInsets from GeometryReader . However, when using GeometryReader , my view doesn't have a fitted size anymore. Code without using GeometryReader struct MyView : View { var body: some View { VStack(alignment: .leading) { CustomView() } .padding(.horizontal) .padding(.bottom, 64) .background(Color.blue) } }

SwiftUI - Using GeometryReader Without Modifying The View Size

谁都会走 提交于 2020-12-01 09:35:08
问题 I have a header view which extends its background to be under the status bar using edgesIgnoringSafeArea . To align the content/subviews of the header view correctly, I need the safeAreaInsets from GeometryReader . However, when using GeometryReader , my view doesn't have a fitted size anymore. Code without using GeometryReader struct MyView : View { var body: some View { VStack(alignment: .leading) { CustomView() } .padding(.horizontal) .padding(.bottom, 64) .background(Color.blue) } }