Search results for

swiftui

16,623 results found

Post

Replies

Boosts

Views

Activity

Reply to Building Lists & Navigation: Extra argument 'id' in call
Did you copy the exact code:struct LandmarkList: View { var body: some View { NavigationView { List(landmarkData) { landmark in NavigationLink(destination: LandmarkDetail(landmark: landmark)) { LandmarkRow(landmark: landmark) } } .navigationBarTitle(Text(Landmarks)) } } }struct LandmarkList_Previews: PreviewProvider { static var previews: some View { ForEach([iPhone SE, iPhone XS Max], id: .self) { deviceName in LandmarkList() .previewDevice(PreviewDevice(rawValue: deviceName)) } }If yes, did you try removing the id argument ?SwiftUI is evolving between each version of XCode and doc may not be updated.Does autocompletion propose you some signature for ForEach ?
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Aug ’19
Reply to UIViewControllerRepresentable and CNContactPickerViewController
I've fixed some things, but I still cannot dismiss it twice in my overall code.import Foundation import SwiftUI import EventKitUI let eventStore = EKEventStore() struct EKEventWrapper: UIViewControllerRepresentable { typealias UIViewControllerType = EKEventEditViewController var theEvent = EKEvent.init(eventStore: eventStore) var coordinator = Coordinator() func makeUIViewController(context: UIViewControllerRepresentableContext<EKEventWrapper>) -> EKEventWrapper.UIViewControllerType { theEvent.startDate = Date() theEvent.endDate = Date() theEvent.title = The Main Event! let calendar = EKCalendar.init(for: .event, eventStore: eventStore) theEvent.calendar = calendar let controller = EKEventEditViewController() controller.event = theEvent controller.eventStore = eventStore controller.editViewDelegate = coordinator as EKEventEditViewDelegate return controller } func updateUIViewController(_ uiViewController: EKEventWrapper.UIViewControllerType, context: UIViewControllerRepresentableContext<E
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Aug ’19
Reply to UIViewControllerRepresentable and CNContactPickerViewController
Sorry to have hijacked the thread, but I got some inspiration, and some examples off of the internet. The thing doesn't work when presented modally, but does work in a VStack with a binding.import Foundation import SwiftUI import EventKitUI let eventStore = EKEventStore() struct EKEventWrapper: UIViewControllerRepresentable { @Binding var isShown: Bool typealias UIViewControllerType = EKEventEditViewController var theEvent = EKEvent.init(eventStore: eventStore) func makeUIViewController(context: UIViewControllerRepresentableContext<EKEventWrapper>) -> EKEventEditViewController { // func makeUIViewController(context: UIViewControllerRepresentableContext<EKEventWrapper>) -> EKEventWrapper.UIViewControllerType { theEvent.startDate = Date() theEvent.endDate = Date() theEvent.title = The Main Event! let calendar = EKCalendar.init(for: .event, eventStore: eventStore) theEvent.calendar = calendar let controller = EKEventEditViewController() controller.event = theEvent controller.eventStore
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Aug ’19
Reply to Presenting a EKEventEditViewController from SwiftUI View
The trick is to embed it inside a ZStack and make it appear via an @Binding.import Foundation import SwiftUI import EventKitUI let eventStore = EKEventStore() struct EKEventWrapper: UIViewControllerRepresentable { @Binding var isShown: Bool typealias UIViewControllerType = EKEventEditViewController var theEvent = EKEvent.init(eventStore: eventStore) func makeUIViewController(context: UIViewControllerRepresentableContext<EKEventWrapper>) -> EKEventEditViewController { // func makeUIViewController(context: UIViewControllerRepresentableContext<EKEventWrapper>) -> EKEventWrapper.UIViewControllerType { theEvent.startDate = Date() theEvent.endDate = Date() theEvent.title = The Main Event! let calendar = EKCalendar.init(for: .event, eventStore: eventStore) theEvent.calendar = calendar let controller = EKEventEditViewController() controller.event = theEvent controller.eventStore = eventStore controller.editViewDelegate = context.coordinator return controller } func updateUIViewController(_
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Aug ’19
SwiftUI Editing the information in the Detail of a Master/Detail
Working on a sample app. The goal is to have a list pulled up from CoreData in a MasterView, and then click on one to go to a DetailView where you can edit the information and save. When you edit the name in the DetailView, it not only updates the DetailView to reflect the change, but it also reflects the change on the MasterView as well. I've tried numerous ways to accomplish this, but so far have not come up with an answer.// Code generation is turned OFF in the xcdatamodeld file public class EntityName: NSManagedObject, Identifiable { @NSManaged public var name: String @NSManaged public var active: Bool } extension EntityName { static func allEntityNameFetchRequest() -> NSFetchRequest<EntityName> { let request: NSFetchRequest<EntityName> = EntityName.fetchRequest() as! NSFetchRequest<EntityName> request.sortDescriptors = [NSSortDescriptor(key: name, ascending: true)] return request } } struct MasterView: View { @Environment(.managedObjectContext) var managedObjectContext @FetchRequest(
1
0
3.8k
Aug ’19
Cannot Preview in this file
I'm running XCode 11.0 Beta 5 on Catalina 10.15. I downloaded the Drawing Paths and Shapes module of the SwiftUI tutorials and Badge.swift and related files throw this error:Landmarks.app crashed: Error Domain=render service Code=12 Rendering service was interrupted UserInfo={NSLocalizedDescription=Rendering service was interrupted}I cleaned the project folder, restarted XCode - still won't preview.Am I missing something?
2
0
1.6k
Aug ’19
Reuse custom alignment in nested views
I have a SwiftUI view for math expressions. It shows divisions as VStacks with a divider in the middle and additions as HStacks with a + sign in the middle. See the images in this GitHub gist: gist.github.com/Dev1an/668978dc4b84b8c6213ba10905d57c1d#proper-alignmentBut I am having trouble aligning the Additions to the Divisions. I can create multiple custom alignment guides beforehand for each division and then everything works fine. But the problem is that I am generating these mathematical expressions dynamically and cannot create new guides (a Type conforming to AlignmentID.Type) for every division in the expression. Is there a way to reuse alignment guides in nested views so that I can reuse the same custom VerticalAlignment multiple times? When I try to reuse the same guide, the HStack's just align to the center (as shown in the gist).Here is an example hierarchy:Addition(alignment: .custom) Division Addition(alignment: .custom) Number + Division Number / (guide: .custom) Number / (guide: .custom
2
0
1.1k
Aug ’19
How to reference current TextField SwiftUI?
I have multiple CustomTextFields and when they are actively being edited I want to know which one is currently active. I have set tags but you can not reference the tag inside the onEditingChanged closure. struct CustomTextField : View { var placeHolderString : String @Binding var contentString. : String var body : some View { TextField(placeHolderString, text: $contentString, onEditingChanged: { (editing) in //Determin which TextField is currently active here }, onCommit: { }).textFieldStyle(RoundedBorderTextFieldStyle()) .multilineTextAlignment(.center) } }
0
0
919
Aug ’19
Reply to Return to storyboard after segue to UIHostingController
Found this tutorial helpful. Hope it will help you as well.h ttps://medium.com/@code_cookies/swiftui-embed-swiftui-view-into-the-storyboard-a6fc96e7a0a1In your case, I would try doing so:- declare une unwind segue action in the UIViewController- in SwiftUI view, create a return button- connect the return button to the exit icon of the SwiftUI view, and select the unwind.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Aug ’19
SwiftUI won't register code elements in the editor
Hello all,I am trying to follow the guide - SwiftUI Essentials: Building Lists and Navigation. However, every time I try to run the preview, I am flagged with Use of undeclared type 'LandmarkRow_previews'. This is after the very first steps of creating a new SwiftUI file and activating the debugger. None of the elements are color coded(i.e. HStack, Text) and only appear in plain white text as if the editor isn't interpreting the code. The issue is only happening in this starter project file provided by apple. Is there any workaround that comes to mind? Thanks, Matt
13
0
5.2k
Aug ’19
Reply to Getting keyboard events from TextField
I think the onCommand(Selector, perform: ()->Void) https://developer.apple.com/documentation/swiftui/view/3367871-oncommandis made for that but I don't know how to use it or if it is already working.None of the `onCopyCommand`, `onCutCommand`, `func onDeleteCommand` and so forth seem to be working in beta 5.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Aug ’19