swiftui

How can I open a local PDF file using a SwiftUI button?

假如想象 提交于 2021-01-04 14:53:50
问题 I want to display a local PDF file through a new view when I tap a button. I tried doing that using a UIViewRepresentable WebView but it's not working (I have worked with WebView only through NavigationList). I leave my code, but feel free to suggest better option if the WebView is not the most optimal. ButtonView import SwiftUI struct ResumeView: View { let sfSymbol: String let text: String let fileUrl = Bundle.main.path(forResource: "Resume", ofType: "pdf") var body: some View {

Can I use View Controller (CalendarKit) in SwiftUI application?

流过昼夜 提交于 2021-01-04 10:38:14
问题 I want to use CalendarKit in my project github here It's written using UIKit, but my project uses SwiftUI. Can I use CustomCalendarExampleController in SwiftUI? (maybe via UIViewControllerRepresentable or smth else?) CustomCalendarExampleController - class CustomCalendarExampleController: DayViewController, DatePickerControllerDelegate { var data = [["Breakfast at Tiffany's", "New York, 5th avenue"], ["Workout", "Tufteparken"], ["Meeting with Alex", "Home", "Oslo, Tjuvholmen"], ["Beach

How to properly use google signIn with SwiftUI

旧巷老猫 提交于 2021-01-04 07:47:05
问题 When I'm trying to sign in and on the next view sign out with GIDSignIn and navigate to previous view everything is fine, but when I'm trying to sign in again, the alert ask App wants to use google sign in , when I press continue - I have an error says: Keyboard cannot present view controllers (attempted to present ) and the next error First responder error: non-key window attempting reload - allowing due to manual keyboard (first responder window is >, key window is ; layer = >) My code

SwiftUI with Core Data getting Blank Screen in simulator in Xcode 12

旧街凉风 提交于 2021-01-04 07:36:47
问题 In XCode 12, if I create a new SwiftUI App and check the "Use Core Data" button, the resulting application (with no changes) shows a blank screen in simulator (as well as on a device). In preview it shows the example timestamps as expected. Why are the simulator/device not showing the example timestamps? 回答1: If you want to see the sample inputs from the template (10 rows with timestamp) in your simulator, you need to change in App.swift: let persistenceController = PersistenceController

SWiftUI anchorPreference inside List

﹥>﹥吖頭↗ 提交于 2021-01-04 06:06:32
问题 I'm using anchorPreferences to set the height of GeometryReader to fit the height of its content. The issue I'm experiencing is, after scrolling up and down the List a few times, the app freezes, the design gets messy, and I get the following message in the console: Bound preference CGFloatPreferenceKey tried to update multiple times per frame. Any ideas how I can fix this? IMPORTANT NOTE: I've simplified my design as much as I could. Here is the code: struct ListAndPreferences: View { var

SWiftUI anchorPreference inside List

妖精的绣舞 提交于 2021-01-04 06:01:28
问题 I'm using anchorPreferences to set the height of GeometryReader to fit the height of its content. The issue I'm experiencing is, after scrolling up and down the List a few times, the app freezes, the design gets messy, and I get the following message in the console: Bound preference CGFloatPreferenceKey tried to update multiple times per frame. Any ideas how I can fix this? IMPORTANT NOTE: I've simplified my design as much as I could. Here is the code: struct ListAndPreferences: View { var

SWiftUI anchorPreference inside List

馋奶兔 提交于 2021-01-04 06:00:29
问题 I'm using anchorPreferences to set the height of GeometryReader to fit the height of its content. The issue I'm experiencing is, after scrolling up and down the List a few times, the app freezes, the design gets messy, and I get the following message in the console: Bound preference CGFloatPreferenceKey tried to update multiple times per frame. Any ideas how I can fix this? IMPORTANT NOTE: I've simplified my design as much as I could. Here is the code: struct ListAndPreferences: View { var

SwiftUI: How to drag and drop a contact from Contacts on macOS

∥☆過路亽.° 提交于 2021-01-03 12:37:15
问题 I'm trying to drag a contact from Contacts into my application. Here is my updated code: import SwiftUI import UniformTypeIdentifiers let uttypes = [UTType.contact, UTType.emailMessage] struct ContentView: View { let dropDelegate = ContactDropDelegate() var body: some View { VStack { Text("Drag your contact here!") .padding(20) } .onDrop(of: uttypes, delegate: dropDelegate) } } struct ContactDropDelegate: DropDelegate { func validateDrop(info: DropInfo) -> Bool { return true } func

SwiftUI: How to drag and drop a contact from Contacts on macOS

﹥>﹥吖頭↗ 提交于 2021-01-03 12:27:35
问题 I'm trying to drag a contact from Contacts into my application. Here is my updated code: import SwiftUI import UniformTypeIdentifiers let uttypes = [UTType.contact, UTType.emailMessage] struct ContentView: View { let dropDelegate = ContactDropDelegate() var body: some View { VStack { Text("Drag your contact here!") .padding(20) } .onDrop(of: uttypes, delegate: dropDelegate) } } struct ContactDropDelegate: DropDelegate { func validateDrop(info: DropInfo) -> Bool { return true } func

SwiftUI Full-Screen UIImagePickerController (Camera)

北慕城南 提交于 2021-01-03 07:08:23
问题 I present a UIImagePickerController within my application by presenting it with logic inside of a sheet modifier. In short, the following three types handle displaying and dismissing a instance of UIImagePickerController inside of a UIViewControllerRepresentable type, which works as expected: struct DetailsView: View { enum Sheet: Hashable, Identifiable { case takePhoto var id: Int { hashValue } } @State private var activeSheet: Sheet? var body: some View { Text("Hello, World!") .sheet(item: