Search results for

swiftui

16,633 results found

Post

Replies

Boosts

Views

Activity

Reply to SwiftUI Tooltips
For the record there appears to be no native way to set a tooltip on a SwiftUI view (feedback #FB7095924), but the following workaround seems to do the trick:public extension View { /// Overlays this view with a view that provides a toolTip with the given string. func toolTip(_ toolTip: String?) -> some View { self.overlay(TooltipView(toolTip)) } } private struct TooltipView: NSViewRepresentable { let toolTip: String? init(_ toolTip: String?) { self.toolTip = toolTip } func makeNSView(context: NSViewRepresentableContext) -> NSView { let view = NSView() view.toolTip = self.toolTip return view } func updateNSView(_ nsView: NSView, context: NSViewRepresentableContext) { } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Sep ’19
Reply to Xcode 11 sims not working
Sorry for duplicate, I posted this yesterday and it disappeared. One can be deleted.I removed Xcode and did a clean install from AppStore. Exactly the same issue still.I can build and run on real device but not simulators. Same issue with missing UVKit.framework loading a SwiftUI project, no canvas and can't run on simulator.Yes, sorry, MacOS 10.15.
Sep ’19
Getting the size of a child
I'm trying to build a FlowStack (a container view that will layout its children on rows, depending on their size and how they fit the parent). The problem I'm facing is that SwiftUI calculates the size of the children (even if implicit) only at a later time, so I can't get it like we used to `view.bounds.width` right after I create the `View` I tried using `anchorPreferences`, these sort of work, however they do not allow me to rearrage the children, but create new ones in foreground or background, so it's a bit useless for my purpose.How can we get the implicit child size from the parent?
0
0
355
Sep ’19
Designing Apps for SwiftUI
The Destination of a NavigationLink is instantiated, but not displayed, when the View with the NavigationLink is instantiated. If the destination view then performs a significant amount of processing every time the origin view changes, but prior to the destination view needing display, there can be significant degradation of app performance. E.g. I've added SwiftUI Views to an existing app in order to analyse accumulated data; the user selects filter and statistics parameters from Pickers prior to pressing the Calculate button (NavigationLInk). The Link destination is instantiated and executed (eg data calculations)every time a property (e.g. filter selection) changes in the origin view before the user has pressed the Calculate button.Also, I assume that all subviews of a View are instantiated when the parent View is instantiated, even though they may not all be on screen. Add to this the fact that ObservedObjects, when changed, trigger a redisplay of any/all? containing Views.So, all of this leads m
3
0
854
Sep ’19
Reply to Designing Apps for SwiftUI
> Do I need to use SwiftUI ?Paraphrasing Hw/S... do you like that storyboards and XIBs rely on a flaky system of connections using actions and outlets, make it hard if not impossible to move between code and visual layouts, and can be messy to use with source control?If you do, then maybe not. Stay where you are and be happy.If you don't, know that SwiftUI sweeps all that away in at least four important ways:There’s a new declarative UI structure that defines how our layouts look and work.Updating the UI preview automatically generates new Swift code, and changing the Swift code updates the UI preview.Any bindings in the Swift – e.g. outlets and actions, effectively – are now checked at compile time, so there’s no more risk of UI failing by surprise at runtime.Although SUI uses controls from UIKit and AppKit behind the scenes, it sits on top of them, effectively making the underlying UI framework an implementation detail rather than something we're forced to care specifically about it.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Sep ’19
App is fine but crashes in App Store Approval on iOS13.1
App was submitted to app store for approval but the binary was rejected as follows:Guideline 2.1 - Performance - App CompletenessWe were unable to review your app as it crashed on launch. We have attached detailed crash logs to help troubleshoot this issue.Next StepsTo resolve this issue, please revise your app and test it on a device to ensure it will launch without crashing.However, the app works perfectly and has been tested on some physical devices,iPhone X and iPad Pro3,each running iOS 12.4.1Also, the app has been tested to work fine on basically any simulator from iOS 11.x up to current 12.4.1 within the XCode test environment.All work perfectly.My current development environment is: macOS 10.14.6 (18G95) (current) XCode Version 10.3 (10G8) (current) Creating apps up to iOS 12.4 (current until 3 days ago) Deplyment target at minimum 11.1The crash report sent by apple review indicates that it crashes on initial load.They are using a simulator @ iOS 13.1I believe this is the problem.I can see that XCode
1
0
2.3k
Sep ’19
Reply to SwiftUI and CoreData
I'm seeing this error in XCode 11 GM seed 1 also. If I access the @FetchRequest in my root View it returns data correctly. If I try to use the same fetch is a child view I get: [SwiftUI] Context in environment is not connected to a persistent store coordinator: <NSManagedObjectContext: 0x2827ac460>. It is like the Environment losses the MOC relationship to the persistent store coordinator in the child views. I think I found a solution for the above issue. I needed to pass the MOC to the child view by adding it to the environment of that view. This allows the FetchRequest in child View (ProspectSelection) to return and not give the above error.ProspectSelection(userData: self.userData, onDismiss: { self.showingSearchCriteria = false self.setModelViewData() }).environment(.managedObjectContext, CoreDataStack.shared.persistentContainer.viewContext)I thought the purpose the an EnvironmentObject is to safely allow every View to access an Object and not passed around. This does not seem to be working
Topic: App & System Services SubTopic: Core OS Tags:
Sep ’19
View disappears when rotating the screen
I made a ImagePicker in SwiftUI to pick a photo from the photo library. When the image was picked and shown by Image in a view, if I rotate the screen from portrait to landscape, the image disappeared. It behaves differently on different devices, e.g. on my colleague's device, the whole screen went black when rotating to landscape. And it is not always reproducible. But once it happens, it happends forever. I saw another post in this forum (https://forums.developer.apple.com/thread/119691) but I am not sure if they are the same issue. To check my code please refer to https://github.com/zjkuang/ImagePickerSwiftUI
1
0
1.5k
Sep ’19
Reply to Xcode 11 beta preview not showing (building)
I am going through the same tutorial and am running into the same problem. I'm running macOS 10.15 (beta) and XCode 11.1 (beta). When I create the SwiftUI View LandmarkList, the preview returns an error and fails to load. But the preview still works for the previously created files (i.e. LandmarkRow).I have tried rebooting but that didn't resolve the issue. If you were able to get this working, your advice would be greatly appreciated!
Topic: App & System Services SubTopic: Core OS Tags:
Sep ’19
Alternative to segue in SwiftUI
So I'm transfering from using the interface builder to using SwiftUI and had a major question: How do we do the same thing we did with segues with SwiftUI? For example just two different views with a button that will send you from one ContentView to another? Sorry this is probably a very basic question but I haven't been able to find any simple solutions to this. Thanks!
1
0
7.1k
Sep ’19
Reply to How i do execute sqlite in iphone?
It's a long time since I've used Objective C with SQLite, but I have a vague recollection of a similar problem to yours. Here's my database opning code from an old app - plus the copy to Documents code. If you use it, you might want to change the sqlite3_open to READONLY not READWRITE. Note the conversion of the path to UTF-8. This part of the old app still compiles and works under iOS 13 and Xcode 11: I still use the app regularly, but have added Swift modules over the years and recently implemented some SwiftUI views.[self installDatabaseIfNeeded]; NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *path = [documentsDirectory stringByAppendingPathComponent:@running.db]; const char *dbpath = [path UTF8String]; // Convert NSString to UTF-8 //NSLog(@Path = %s,dbpath); retcode = sqlite3_open_v2(dbpath, &runningDB, SQLITE_OPEN_READWRITE, NULL);...........- (void) installDatabaseIfNeeded {
Sep ’19