Search results for

swiftui

16,582 results found

Post

Replies

Boosts

Views

Activity

Reply to Is SwiftUI backwards compatible with iOS 12 and below?
I would really like to hear an official statement on backward compatibility for SwiftUI from Apple. The library annotations make me think I won't like what their position will be, but I need some closure on this issue. Personally, I am looking ahead to revamping some UI code so my app will pass the fully size adaptive requirement for App Store acceptance that will be in force in April. And I need to know, is there any hope that I can use SwiftUI for it?
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jun ’19
SwiftUI Inputs
In the Landmark demo if you enter a username in the username textfield, the textfield gets expanded over the hstack. Is it possible to limit the size somehow?
0
0
433
Jun ’19
How to Check User Interface Appearance
Is it possible to check whether the user has dark/light mode enabled and adjust an interface accordingly? I’m looking to do this with colors in SpriteKit (or anything other than UIKit or SwiftUI, technically) based on the device’s global setting rather than an app setting.
1
0
5.3k
Jun ’19
Multi-Component Picker
Can one create a multi-component Picker in SwiftUI (where in UIKit the data source would return a number other than 1 from the numberOfComponents method)?I can fall back to an HStack of single-component Pickers, but the perspective effect is off.
0
0
635
Jun ’19
New UI Element colors in SwiftUI
Is there an easy way to get the new adaptive UI element colors (systemBackground, secondaryLabel, etc.) in SwiftUI? I know that I could write a class to bridge to UIColor and do the getRed(green:blue:alpha:) dance, but it seems like there should be a simpler approach. I know understand that these colors are used automatically in some cases, but it seems like custom controls would benefit from having them available. Am I misunderstanding the role of the UI element colors in SwiftUI?—Chris
10
0
9.5k
Jun ’19
Reply to Is there a limit to the number of files using VStacks
You're creating your own type named “Slider”, but SwiftUI already has a type named “Slider”. Your Slider type doesn't have an init compatible with the signature init(value: Binding<Double>, from: Double, through: Double, by: Double), so the attempt to create a Slider inside the VStack fails and generates the “Unable to infer complex closure return type” error.I can make your code compile by explicitly creating the nested Slider using the SwiftUI module name:struct Slider : View { @State var celsius: Double = 0 var body: some View { VStack { SwiftUI.Slider(value: $celsius, from: -100.00, through: 100.00, by: 1.0) Text((celsius) Celsius is (celsius * 9 / 5 + 32) Fahrenheit) } } }Realistically, this is not a good solution. You should not make your own type named “Slider”. You should rename your type to something else like “TemperatureControl”.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jun ’19
Reply to Integrating SwiftUI into existing project
A SwiftUI file created from the default template includes a PreviewProvider guarded by an `#if DEBUG` statement. In order to include this in the binary used by Xcode's preview cancas, open your project settings, expand Active Compilation Conditions (SWIFT_ACTIVE_COMPILATION_CONDITIONS) and add DEBUG in the debug configuration.
Topic: App & System Services SubTopic: Core OS Tags:
Jun ’19
Not quite grokking declarative syntax
I'm having trouble wrapping my head around SwiftUI's declarative syntax. For instance, in the Landmarks code, when creating the List ...var body: some View { NavigationView { List(landmarkData) { landmark in NavigationButton(destination:LandmarkDetail()) { LandmarkRow(landmark: landmark) } }.navigationBarTitle(Text(Landmarks)) } }... why is the navigationBarTitle associated with the List? I *think* it's analagous to UINavigationControllers, where each UITableViewController has a navigationItem (and a title). Is that right?More confusingly (for me), why is the LandmarkRow inside the NavigationButton? I think of a button as part of a UITableViewCell, so here the analogy breaks down. Can someone explain this?
6
0
1.3k
Jun ’19
Reply to Is SwiftUI backwards compatible with iOS 12 and below?
This isn't actually about module stability, though. In spite of its name, SwiftUI isn't part of Swift (though the syntax used to declare Views in SwiftUI is part of Swift 5.1+). The functions in the SwiftUI are just new Apple APIs.Like always, these are only going to be available on existing OS releases if Apple makes new dot (minor) versions. That can make new API available for users who update to a new dot version, without a major version upgrade. That *can* happen, but it usually doesn't.(Actually, some APIs turn out to backwards compatible because they *existed* in older versions of the OS, but weren't *public*. But this doesn't happen very often.)IDK, but it seems to me that *new* apps using SwiftUI are going to start appearing much sooner than *revisions* of existing apps with SwiftUI. That's because the cost of conversion is likely pretty high, and perhaps not worth paying for code that is already working. (And it's probably easier to generalize the layout o
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jun ’19
Reply to Core Data Model SwiftUI
The most likely recommended strategy is to create a view model for each item you want to pass to your SwiftUI view, along with a datasource class with properites for a PassthroughDataSource, NSFetchedResultsController and an array of view models.Set your datasource as the results controller delegate and configure your results contrller fetch predicate. Your view model should have an initalizer that takes an NSManagedObject and sets the properties you want to display in your UI. When the delegte method is called, enumerate over the results, create view models initalized with the resulting core data objects, append them to the array, then call send(.self) on your PassThroughSubject.I usually add a createSampleData() method that populates the same array with hard coded view models initalized with test data for use with the preview provided. class MyManagedObject: NSManagedObject { @NSManaged var name: String? @NSManaged var age: NSNumber? } struct MyViewModel { var name: String var age: String init(mana
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jun ’19
Reply to How to pop a NavigationButton programmatically?
Hi guys, I'm new to Apple development world, and I'm learning SwiftUI, looking for navigation things I found this thread.Looking further I've noticed the EditMode used with the EditButton, and it uses the Environment of EditMode to toggles it.I looked in the autocomplete of the available Environment properties and found an interesting one, isPresented.@Environment(.isPresented) var isPresentedWith this property inside my detail view, I could close programmatically a Presentation View, by just callingisPresented?.animation().value = falseNow we need some lights with the NavigationButton 😁.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jun ’19
Shape Modifier Chains
When I attempt to apply multiple modifiers to a shape, Xcode throws an error letting me know the value does not have that member. e.g.Circle().fill(Color.red).stroke(Color.white, lineWidth: 2)The code above shows the following error:Value of type 'ShapeView<Circle, Color>' has no member 'stroke'It was my impression the power of SwiftUI is it's ability to create custom UI through the use of modifier chains.
0
0
601
Jun ’19
UIToolbar in SwiftUI?
I've been experimenting with SwiftUI and couldn't figure out how to get a simple UIToolbar to appear at the bottom of the screen.Basic view:struct MyView : View { var body: some View { NavigationView { List { NavigationButton(destination: Text(1)) { Text(Element 1) } // ... }.navigationBarTitle(Text(Elements)) } } }
4
0
8.5k
Jun ’19
Error (but no error) with Canvas when trying to run SwiftUI Landmark
I have been working throught the SwiftUI demo code tasks from this website and up until now have not had an issue. On the most recent step (https://developer.apple.com/tutorials/swiftui/handling-user-input Section 2 Part 2), I attempted to run the application using the new Canvas feature, only for the canvas preview to start consistently crashing (even with the code added in that section commented out), but when you ask for the Diagnostics the error code is mainly: Landmarks.app: no underlying error. There is though sometimes the error: Landmarks.app: Error Domain=render service Code=12 Rendering service was interrupted UserInfo={NSLocalizedDescription=Rendering service was interrupted}, which I can't locate online anywhere other than one chinese language website. Has anyone any idea wether this is something to do with the code I've been writing or is this a bug in SwiftUI in XCode 11 Beta? Or any suggestions on a fix? Thanks in advance! (NOTE: Xcode 11 beta (11M336w) and the first
8
0
8.7k
Jun ’19