Search results for

swiftui

16,632 results found

Post

Replies

Boosts

Views

Activity

Substitute for NavigationView on Watch
Hi,I believe NavigationView is not available on SwiftUI for the Watch. What would I use in its place? I have a menu list which I want to add enable each item to be pressed to move to another view.import SwiftUI struct ContentView : View { var body: some View { List { HStack { Image(systemName: rectangle.on.rectangle.angled) Text(Study) .listRowPlatterColor(Color.gray) .frame(height:50) } HStack { Image(systemName: star.fill) Text(Favourites) .listRowPlatterColor(Color.gray) .frame(height:50) } HStack { Image(systemName: gear) Text(Settings) .listRowPlatterColor(Color.gray) .frame(height:50) } } .listStyle(.carousel) }Thanks.
1
0
982
Sep ’19
Reply to SwiftUI page-based navigation in watchOS
Did you manage to get page-based navigation working in SwiftUI?I have have set it by adding each page as a seperate hosting controller in the interface builder however I would like to be able to do it purely in code to help improve the initial onboarding process (i.e. only have one page until they have gone done the onboarding)
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Sep ’19
How to tie NSFetchedResultsController to List
I've got a simple data model that includes a PassthroughSubject like so:final class PeopleDataModel: NSObject, ObservableObject { var didChange = PassthroughSubject<Void, Never>() private lazy var fetchedResultsController: NSFetchedResultsController<Person> = { ... }() public var people: [Person] { return fetchedResultsController.fetchedObjects ?? [] } } extension PeopleDataModel: NSFetchedResultsControllerDelegate { func controllerDidChangeContent(_ controller: NSFetchedResultsController<NSFetchRequestResult>) { people.forEach { print($0) } didChange.send() } }So my intent is when Core Data is updated, it'll send the message out. Now I try and use it in my SwiftUI view:struct ContentView : View { @ObservedObject var peopleDataModel = PeopleDataModel() var body: some View { NavigationView { List(peopleDataModel.people) { person in NavigationLink(destination: PersonDetailView(person: person)) { PersonRow(person: person) } } .navigationBarTitle(Text(People)) } } }The view doesn't actu
1
0
1.5k
Sep ’19
Reply to SwiftUI and ARKit
Now that is a question!I am looking at that right now and yes the latest relerase does support SwiftUI withj realityKit, but it is not clear how you get at things like ARWorldConfiguration settings etc in SwiftUI. If you are happy to accept many of the default settings this might work for you... Me - I have need of things to fiddle with for my applications... If you get a good solution please let me know..
Topic: Spatial Computing SubTopic: ARKit Tags:
Sep ’19
UILabel word wrapping in SwiftUI
Hello!I'm trying to use a UILabel in a tree of SwiftUI views, creating a View Struct that conforms to UIViewRepresentable. The reason for using UILabel instead of the native SwiftUI Text() view is that I would like to display an NSAttributedString.The UILabel renders in the SwiftUI view, however the words do not wrap to become multi-line on the screen. Instead, the text just chops off at the trailing edge. The same UILabel settings in a purely UIKit based ViewController setup wrap correctly, for comparison. Providing a plain string to UILabel.text or an attributed string to UILabel.attributedText yields the same non-wrapping results.I am just wondering if anyone has got this to work, or knows where I might be going wrong? Here is the view struct:struct UIKitLabelView : UIViewRepresentable { typealias UIViewType = UILabel func makeUIView(context: UIViewRepresentableContext<UIKitLabelView>) -> UILabel { let label = UILabel() label.translatesAutoresizingMaskIntoConstraints = f
3
0
11k
Sep ’19
SwiftUI List reload causes crash
I get a crash when reloading a List based on some search results. The results may change out the sections and rows. The error returned looks like an internal error because sometimes it works and sometimes it crashes on the same search string.Error:Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Attempt to create two animations for cell' *** First throw call stack: ( 0 CoreFoundation 0x00007fff23afdbde __exceptionPreprocess + 350 1 libobjc.A.dylib 0x00007fff5015cb20 objc_exception_throw + 48 2 CoreFoundation 0x00007fff23afd958 +[NSException raise:format:arguments:] + 88 3 Foundation 0x00007fff255506f5 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 191 4 UIKitCore 0x00007fff47134191 -[_UITableViewUpdateSupport(Private) _setupAnimationsForNewlyInsertedCells] + 1575 5 UIKitCore 0x00007fff4713ef73 -[_UITableViewUpdateSupport _setupAnimations] + 118 6 UIKitCore 0x00007fff470d5ec4 -[UITableView _updateWithItems:updateSupport:] + 2883 7 UIKitCo
3
0
5.5k
Sep ’19
Using Multiple WKHostingControllers
Using SwiftUI I'm trying to recreate an existing watch app.The app has multiple pages accessed via the next page segue.If I have a single WKHostingController the @environment object works as described.However if I try to access the @environment variable from a View instanitiated with a different WKHostingController I get the following error:Fatal error: No observable object of type VetUserSettings.Type found. where VetUserSetting is intially set in the WKHostingController instantiation of the first page.
0
0
784
Sep ’19
Nested spacers and height
It looks like spacers provide spacing dependant only on their parent view's context, so something likeVStack { ViewA() Spacer() ViewB() Spacer() ViewC() }will equally distribute spacing, but the following will not render equivalently. The outer spacer will push ViewBC down as far as possible, and then the spacer in ViewBC will do its thing (but usually will end up doing nothing because the outer spacer already took all the available spacing)VStack { ViewA() Spacer() ViewBC() }where ViewBC is defined asVStack{ ViewB() Spacer() ViewC() }Bundling into ViewBC can be useful in situations where components that are reused often. So what's the workaround? Is there a way to tell SwiftUI that I want ViewBC to consume more of the available space? Or is the idiomatic expecation to render all components at the same level?
0
0
487
Sep ’19
How to put multiple buttons and other controls in a tab in swiftUI
is there any sample code showing how to put multiple controls in a tab for a macOS app? I have an app that I'd like to use as a basis for swiftUi work, but it's not oh look, here's some scrolly things and it's all really iOS navigation. It's a macOS app, it has specific window sizes, multiple buttons in specific places in a tab, multiple text fields, table views, popup lists, etc. Each tab is different. I can't find any good info that isn't so targeted at iOS to be useless for my needs.
0
0
846
Sep ’19
Reply to SwiftUI and ARKit
You can configure the ARView through the use of a UIViewRepresentable container. If you create a new AR project in Xcode 11 and specify that you would like to use both RealityKit and SwiftUI most of the infrastructure needed is created for you. I recommend that you take a look at the Interfacing with UIKit SwiftUI tutorial, which shows you how you can interact with UIViews in SwiftUI: https://developer.apple.com/tutorials/swiftui/interfacing-with-uikit
Topic: Spatial Computing SubTopic: ARKit Tags:
Sep ’19
View as a Parameter / Variable in SwiftUI
Hi, all!Still trying to wrap my brain around SwiftUI and how different it is from UIKit stuff.I've created a View called DraggableView which runs a closure when it's being dragged. I made it so that this view could accept as a variable in its constructor any other generic view, and it would essentially put that view into a draggable container. I had to construct it like so:DraggableView: View { var containedView: Content ... }And it seems to work. The DraggableView gets a container view and displays it properly.In the drag closure, I want the DraggableView to be able to pass back the view it was constructed with (A duplicate view of its insides).I don't know if it's because of Opaque return types or something, but I'm really confused at passing views around in general. I can't just have it expect a UIView like I used to be able to and that kind of *****.My drag closure looks like so right now and I'm getting all kinds of errors. I don't even really know what AnyView is but can't find any good documen
8
0
24k
Sep ’19
Reply to View as a Parameter / Variable in SwiftUI
Doc on AnyView (not very good):https://developer.apple.com/documentation/swiftui/anyviewWhere did you find that you have to pass AnyView for the closure ?I found this SO interesting:https://stackoverflow.com/questions/56833659/what-is-content-in-swiftuiCould you show the errors you get ?
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Sep ’19