Search results for

swiftui

16,626 results found

Post

Replies

Boosts

Views

Activity

Reply to Swiftui list row with multiple buttons?
I'm having the same issue. I was wondering if we can simply tell SwiftUI to not do its default behavior. I experimented with .lineStyle(nil), but it didn't work. Does anyone know a way to tell SwiftUI to ignore its default behavior (namely, the 3 points mentioned in the first post)?
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Aug ’19
Storyboards deprecated w/ SwiftUI or not?
Hi guys,So now that SwiftUI is coming out in xCode 11. Should we keep using storyboards and xib files going forward, or should we only use SwiftUI going forward, and eventually migrate storyboards over? Will it be possible to configure projects to use SwiftUI as splash screen instead of having storyboard? What about main.storyboard?Because now there are several ways of doing same thing, I'm assuming some of it is going to be deprecated in a long run?Thanks,Chris
4
0
7.8k
Aug ’19
Reply to Storyboards deprecated w/ SwiftUI or not?
SwiftUI is not replacing storyboards ; it may replace xib in some cases.But IMHO, SwiftUI is still far from providing the capabilities of xib. Just read in SwiftUI forum to see how developers are struggling to replicate what is easily done with xib and storyboards and autoLayout.In addition, I find SwiftUI verbose, with the succession of .attributes(). But that may be just a question of practice.So, I don't fear storyboards and xib to disappear in the next 5 years ; and I will keep using them.
Aug ’19
Reply to Storyboards deprecated w/ SwiftUI or not?
Might want to ask yourself if you intend to include support for < iOS 13...If you do, you can't use SwiftUI alone, but you can still use Xcode 11 w/deployement set lower, so...see https://forums.developer.apple.com/message/364021#364021I expect a mix for some time...look how long XIBs hung around after Storyboards came out.
Aug ’19
Xcode-beta strange behaviours
Hello everyone,I'm new to iOS Developing and also to the SwiftUI, and I am following along with the https://developer.apple.com/tutorials/swiftui/building-lists-and-navigation (on OS 10.15 Catalina & Xcode 11.0 beta-6).However, Xcode is behaving quite strange, like when I create a new SwiftUI view it leads errors previewing it, although the downloaded files work just fine. In addition, it does not auto-complete. Any suggestions ?Thanks in advance.
0
0
426
Aug ’19
NSManagedObject does not update SwiftUI view
NSManagedObject is a subclass of ObservableObject and is a publisher acccording to 10:13 of WWDC19-230 so it’s expected that it will publish attributes changes and trigger the SwiftUI view updates.However in the following snippet the TextField.disabled never gets updated, even though managedEntity.enabled attribute changed on the line 10 with the Toggle.@objc(ManagedEntity) public class ManagedEntity: NSManagedObject { @NSManaged public var name: String // = Managed Entity @NSManaged public var enabled: Bool // = false } struct ContentView: View { @ObservedObject var managedEntity: ManagedEntity var body: some View { VStack { Toggle(ManagedEntity enabled, isOn: $managedEntity.enabled) TextField(ManagedEntity name, text: $managedEntity.name) .disabled(!managedEntity.enabled) } } }The same pattern works if I use my own subclass of ObservableObject with @Published attributes, also I see NSManagedObjects publishers update assigned UIKit views, but not the SwiftUI.I'm afraid I might be missing some import
2
0
4.4k
Aug ’19
Views do not update inside the ForEach in SwiftUI
I'm using a ForEach to parse a list of models and create a view for each of them, Each view contains a Button and a Text, the Button toggles a visibility state which should hide the text and change the Button's title (Invisible/Visible).struct ContentView: View { @State var colors: [MyColor] = [MyColor(val: Blue), MyColor(val: Yellow), MyColor(val: Red)] var body: some View { ForEach(colors, id: .uuid) { color in ButtonColorView(color: color.val) } } } struct ButtonColorView: View { var color: String @State var visible = true var body: some View { if visible { return AnyView( HStack { Button(Invisible) { self.visible.toggle() } Text(color) }) } else { return AnyView( Button(Visible) { self.visible.toggle() } ) } } } class MyColor: Identifiable { let uuid = UUID() let val: String init(val: String) { self.val = val } }Unfortunately it's not working, the views inside the ForEach do not change when the Button is pressed. I replaced the Foreach with ButtonColorView(color: colors[0].val) and it seems to work, so I'
2
0
8.7k
Aug ’19
Swiftui real time graph
Hello there,I would like to ask for a little help. I am working on a macos application for university hand-in, that is capable of drawing real time linegraph. Since the change in the frameworks (I'm already on macos Catalina) I would like to pre_adapt it to swift UI library. I looked at core graphics(seems like not made for the job), core image and alike also not made for simple 2D real time graphs(correct me if I'm wrong). Is it even possible to make a plotting linegraph application for macOs without going down to metal api and such or I should turn to 3rd party libraries?(I'm a newcomer, please be indulgent)Thank you for your help in advance, any help is welcome.Greetings,Zahovay
2
0
3.6k
Aug ’19
Weird behaviour with a VStack in an HStack
Hi,I have multiple Text views stacked vertically in a VStack, then something to the right of the VStack, let's say an image.But when I have more than 1 Text view all of the Text views truncate! If I only have 1 Text view, it dynamically sizes the width as expected to the right image, and wraps the text to multiple lines if needed.Using the SwiftUI tutorial files, a basic visual of what's happening would be this:When really what I'm aiming for is for the Text to be wrapped onto multiple lines and not truncated like this:How do I maintain 2 or more Text views in the VStack without truncating each?The code is as follows:var body: some View { HStack(alignment: .center) { VStack(alignment: .leading, spacing: 5) { Text(landmark.name) .background(Color.purple) Text(landmark.name) .background(Color.green) } Spacer() landmark.image .resizable() .frame(width: 50, height: 50) } }
0
0
939
Aug ’19
Slow List refresh when using coredata NSFetchedResultsController
I'm making a test with SwiftUI and my app (that uses coredata) and I'm having some problems.I managed to make to work NSFetchedResultsController and it works nicely. The problem occurs when I made searches (changing the predicate) and the List must update the changes. It seems that not only the visible rows are compared between the old and new fetchedObjets (as before with the old UITableView), but the entire list and that is extremely slow.The logs that I'm seeing with SQLDebug level 4 are showing me that all objets are being loaded in batches of 20 objets (fetchBatchSize = 20).This is my code for the List View:struct OrderListView: View { @ObservedObject var searchOrderFilter: SearchOrderFilter var body: some View { List { SearchView(searchText: $searchOrderFilter.searchText, selectedOption: $searchOrderFilter.selectedOptionIndex, placeholder: Search, options: [Address, Work, Client, Phone, PO]) ForEach(searchOrderFilter.fetchedResultsController.fetchedObjects!, id: .objectID) { (order) in OrderCel
3
0
2.8k
Aug ’19
App crashes after macOS 10.15 Beta 7
After updating to macOS 10.15 Beta 7 my macOS App using SwiftUI crashes immediately. Same behavior with both Xcode Beta 6 and Xcode Beta 7. I've tried clearing derived data, etc.The runtime error is:dyld: Symbol not found: _$s7SwiftUI7BindingVyxGSkAASMRzSkRzSH5IndexSlRpzlMcHas anyone run into this?
10
0
2.6k
Aug ’19
Adding a drag gesture to a View inside a ScrollView blocks the scrolling
So I have a ScrollView holding a set of views:ScrollView { ForEach(setOfData) { data in NavigationLink(destination: ...) { CustomView(data: data) } .buttonStyle(BackgroundButtonStyle()) } }In a CustomView I have a drag gesture:let drag = DragGesture() .updating($gestureState) { value, gestureState, _ in // ... } .onEnded { value in // ... }Which I assign to a part of the view:ZStack(alignment: .leading) { HStack { // ... } HStack { // ... } .gesture(drag) // or .simultaneousGesture(drag) }As soon as I attach the gesture, the ScrollView stop scrolling. The only way to make it scroll it to start scrolling from a part of it which has no gesture attached. How can I avoid it and make them both work together. In UIKit is was as simple as specifying true in shouldRecognizeSimultaneouslyWithmethod. How can I have the same in SwiftUI?In SwiftUI I've tried attaching a gesture using .simultaneousGesture(drag) and .highPriorityGesture(drag) – they all work the same as .gesture(drag). I've also tried pro
2
0
5.2k
Aug ’19
Reply to UIViewRepresentable of UITextView in SwiftUI layout issues
Have you had any luck with this? I've played around a bit with changing hugging and restance priorities and get it closer to what it needs to be, but the vertical size is still wrong...import SwiftUI struct UITextViewContainer: UIViewRepresentable { let text: String func makeUIView(context: UIViewRepresentableContext<Self>) -> UITextView { let view = UITextView() view.isScrollEnabled = false view.isEditable = false view.dataDetectorTypes = .all view.isSelectable = true return view } func updateUIView(_ uiView: UITextView, context: UIViewRepresentableContext<Self>) { uiView.text = self.text uiView.setContentHuggingPriority(.defaultHigh, for: .vertical) uiView.setContentHuggingPriority(.defaultHigh, for: .horizontal) uiView.setContentCompressionResistancePriority(.defaultLow, for: .horizontal) uiView.setContentCompressionResistancePriority(.required, for: .vertical) } } #if DEBUG struct UITextViewContainer_Previews: PreviewProvider { static var previews: some View { VStack { UITextViewCo
Topic: App & System Services SubTopic: Core OS Tags:
Aug ’19
How to use SwiftUI to display a map and handle touch on the map?
I want to use SwiftUI to display a map and handle touch on the map. Here is my code so far. I have a problem integrating GestureRecognizer in Coordinator specifically accessing self.mapView inside it.Also adding addGestureRecognizer. How to do that?=======================================//// ContentView.swiftimport SwiftUIimport Gomobiletidbstruct ContentView: View { var body: some View { VStack { MapView() .edgesIgnoringSafeArea(.vertical) Text(Turtle Rock) .font(.title) .padding(.leading, 15) .padding(.top, 5) .textFieldStyle(RoundedBorderTextFieldStyle()) VStack { HStack { Text(Joshua Tree National Park) .font(.subheadline) Spacer() Text(California) .font(.subheadline) } .padding() } }}=======================================//// MapView.swiftimport SwiftUIimport MapKitstruct MapView: UIViewRepresentable { func makeCoordinator() -> Coordinator { Coordinator(self) } final class Coordinator: NSObject, MKMapViewDelegate { var control: MapView init(_ control: MapView) { self.control = control longPr
1
0
3.8k
Aug ’19
Reply to Swiftui real time graph
Hi,Maybe I miss something, and I didn't really make graphics for now with SwiftUI, excepted the tutorial, but if you start by doing the SwiftUI tutorial you will see that all the 2 graphics object. are there to do something valuable : https://developer.apple.com/tutorials/swiftui/drawing-paths-and-shapes (a good thing to do the tutorial from thee beginning.I am not aware of the speed you need to make you real time display of data, but for 2D rendering I think that you have plenty of power available.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Aug ’19