Explore the various UI frameworks available for building app interfaces. Discuss the use cases for different frameworks, share best practices, and get help with specific framework-related questions.

All subtopics

Post

Replies

Boosts

Views

Activity

How the input of UITextField is stored ?
When user enters in a textfield, is the input of textfield gets stored in a String ? If yes, then String in swift being immutable, as user keeps on typing does new memory for storing that text gets allocated with each key stroke ? And when we read users input by using delegate method textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) from textfield.text, we get users input in a String. Is it same storage as used by textfield for storing the user input on key stroke or is it some other storage with copy of the user's input in it? Or is UItextfield using a diffrent data structure (buffer) for storing the user input and when we do textfield.text, it gives a copy of data stored in original buffer?
1
0
75
10h
Fatal Exception: NSInternalInconsistencyException Attempting to select a view controller that isn't a child! (null)
When call: [UITabBarController setViewControllers:animated:] It crashed and raise an Fatal Exception: Fatal Exception: NSInternalInconsistencyException Attempting to select a view controller that isn't a child! (null) the crash stack is: Fatal Exception: NSInternalInconsistencyException 0 CoreFoundation 0x8408c __exceptionPreprocess 1 libobjc.A.dylib 0x172e4 objc_exception_throw 2 Foundation 0x82215c _userInfoForFileAndLine 3 UIKitCore 0x38a468 -[UITabBarController transitionFromViewController:toViewController:transition:shouldSetSelected:] 4 UIKitCore 0x3fa8a4 -[UITabBarController _setSelectedViewController:performUpdates:] 5 UIKitCore 0x3fa710 -[UITabBarController setSelectedIndex:] 6 UIKitCore 0x8a5fc +[UIView(Animation) performWithoutAnimation:] 7 UIKitCore 0x3e54e0 -[UITabBarController _setViewControllers:animated:] 8 UIKitCore 0x45d7a0 -[UITabBarController setViewControllers:animated:] And it appear sometimes, what's the root cause?
1
0
67
13h
Discovered a bug where Alert button colors are changed by the tint modifier.
I used .tint(.yellow) to change the default back button color. However, I noticed that the color of the alert button text, except for .destructive, also changed. Is this a bug or Apple’s intended behavior? this occurs in iOS 18.1 and 18.1.1 Below is my code: // App struct TintTestApp: App { var body: some Scene { WindowGroup { MainView() .tint(.yellow) } } } // MainView var mainContent: some View { Text("Next") .foregroundStyle(.white) .onTapGesture { isShowingAlert = true } .alert("Go Next View", isPresented: $isShowingAlert) { Button("ok", role: .destructive) { isNextButtonTapped = true } Button("cancel", role: .cancel) { } } } thank you!
0
0
48
15h
Since iOS 18.1, the color of Alert buttons has been affected by the tint modifier.
I used .tint(.yellow) to change the default back button color. However, I noticed that the color of the alert button text, except for .destructive, also changed. Is this a bug or Apple’s intended behavior? Thank you! Below is my code: // App struct tintTestApp: App { var body: some Scene { WindowGroup { MainView() .tint(.yellow) } } // MainView var mainContent: some View { Text("Next") .foregroundStyle(.white) .onTapGesture { isShowingAlert = true } .alert("Go Next View", isPresented: $isShowingAlert) { Button("ok", role: .destructive) { isNextButtonTapped = true } Button("cancel", role: .cancel){} } }
2
1
43
15h
Customizing Tables in SwiftUI
Hi, How to customize tables in SwiftUI its color background for example, the background modifier doesn't work ? how to change separator lines ? rows background colors ? give header row different colors to its text and background color ? Kind Regards
1
0
55
15h
Relationship between CABasicAnimation's KeyPath and a CALayer's action event
I have a CALayer and I'd like to animate a property on it. But, the property that triggers the animation change is different to the one that is being changed. A basic example of what I'm trying to do is below. I'm trying to create an animation on count by changing triggerProperty. This example is simplified (in my project, the triggerProperty is not an Int, but a more complex non-animatable type. So, I'm trying to animate it by creating animations for some of it's properties that can be matched to CABasicAnimation - and rendering a version of that class based on the interpolated values). @objc class AnimatableLayer: CALayer { @NSManaged var triggerProperty: Int @NSManaged var count: Int override init() { super.init() triggerProperty = 1 setNeedsDisplay() } override init(layer: Any) { super.init(layer: layer) } required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") } override class func needsDisplay(forKey key: String) -> Bool { return key == String(keypath: \AnimatableLayer.triggerProperty) || super.needsDisplay(forKey: key) } override func action(forKey event: String) -> (any CAAction)? { if event == String(keypath: \AnimatableLayer.triggerProperty) { if let presentation = self.presentation() { let keyPath = String(keypath: \AnimatableLayer.count) let animation = CABasicAnimation(keyPath: keyPath) animation.duration = 2.0 animation.timingFunction = CAMediaTimingFunction(name: CAMediaTimingFunctionName.linear) animation.fromValue = presentation.count animation.toValue = 10 return animation } } return super.action(forKey: event) } override func draw(in ctx: CGContext) { print("draw") NSGraphicsContext.saveGraphicsState() let nsctx = NSGraphicsContext(cgContext: ctx, flipped: true) // create NSGraphicsContext NSGraphicsContext.current = nsctx // set current context let renderText = NSAttributedString(string: "\(self.presentation()?.count ?? self.count)", attributes: [.font: NSFont.systemFont(ofSize: 30)]) renderText.draw(in: bounds) NSGraphicsContext.restoreGraphicsState() } func animate() { print("animate") self.triggerProperty = 10 } } With this code, the animation isn't triggered. It seems to get triggered only if the animation's keypath matches the one on the event (in the action func). Is it possible to do something like this?
1
0
52
17h
Macos 15.2 beta 4 App Crash
I have a SwiftUI based program that has compiled and run consistently on previous macos versions. After upgrading to 15.2 beta 4 to address a known issue with TabView in 15.1.1, my app is now entering a severe hang and crashing with: "The window has been marked as needing another Update Contraints in Window pass, but it has already had more Update Constraints in Window passes than there are views in the window. .<SwiftUI.AppKitWindow: 0x11d82a800> 0x87 (2071) {{44,0},{1468,883}} en" Is there a known bug that could be causing this crash or known change in the underlying layout model?
0
0
75
19h
Horizontal window/map on visionOS
Hi, would anyone be so kind and try to guide me, which technologies, Kits, APIs, approaches etc. are useful for creating a horizontal window with map (preferrably MapKit) on visionOS using SwiftUI? I was hoping to achieve scenario: User can walk around and interact with horizontal map window and also interact with (3D) pins on the map. Similar thing was done by SAP in their "SAP Analytics Cloud" app (second image from top). Since I am complete beginner in this area, I was looking for a clean, simple solution. I need to know, if AR/RealityKit is necessary or is this achievable only using native SwiftUI? I tried using just Map() with .rotation3DEffect() which actually makes the map horizontal, but gestures on the map are out of sync and I really dont know, if this approach is valid or complete rubbish. Any feedback appreciated.
0
0
57
22h
sourceImageURL in imagePlaygroundSheet isn't optional
I can't shake the "I don't think I did this correctly" feeling about a change I'm making for Image Playground support. When you create an image via an Image Playground sheet it returns a URL pointing to where the image is temporarily stored. Just like the Image Playground app I want the user to be able to decide to edit that image more. The Image Playground sheet lets you pass in a source URL for an image to start with, which is perfect because I could pass in the URL of that temp image. But the URL is NOT optional. So what do I populate it with when the user is starting from scratch? A friendly AI told me to use URL(string: "")! but that crashes when it gets forced unwrapped. URL(string: "about:blank")! seems to work in that it is ignored (and doesn't crash) when I have the user create the initial image (that shouldn't have a source image). This feels super clunky to me. Am I overlooking something?
0
0
58
1d
Most idiotic problem with assign value to value?
Why assigning function.formula = formula does not change function.formula to formula in one go? It's always late one change behind. struct CustomFunction has defined .formula as @MainActor. I feel stupid. There is a part of code: struct CustomFormulaView: View { @Binding var function: CustomFunction @State var testFormula: String = "" @EnvironmentObject var manager: Manager .... .onChange(of: testFormula) { debugPrint("change of test formula: \(testFormula)") switch function.checkFormula(testFormula, on: manager.finalSize) { case .success(let formula): debugPrint("before Change: \(function.formula)") function.formula = formula // Nothing happens debugPrint("Test formula changed: \(testFormula)") debugPrint("set to success: \(formula)") debugPrint("what inside function? \(function.formula)") Task { //Generate Image testImage = await function.image( size: testImageSize), simulate: manager.finalSize) debugPrint("test image updated for: \(function.formula)") } .... and it produces this output when changed from 0.5 to 1.0 Debug: change of test formula: 1.0 Debug: before Change: 0.5 Debug: Test formula changed: 1.0 Debug: set to success: 1.0 Debug: what inside function? 0.5 Debug: test image updated for: 0.5 0.5 is an old value, function.formula should be 1.0 WT??
3
0
107
1d
Share sheet configuration
I'm trying to configure the share sheet. My project uses techniques from the Apple Sample project called CoreDataCloudKitShare which is found here: https://developer.apple.com/documentation/coredata/sharing_core_data_objects_between_icloud_users# In this sample code there's a "PersistenceController" which is an NSPersistentCloudKitContainer. In the "PersistenceController+SharingUtilities" file there are some extensions, and one of them is this: func configure(share: CKShare, with photo: Photo? = nil) { share[CKShare.SystemFieldKey.title] = "A cool photo" } This text "A cool photo" seems to be the only bespoke configuration of the share sheet within this project. I want to have more options to control the share sheet, does anyone know how this might be achieved? Thank you!
0
0
44
1d
In SwiftUI in iOS 18.1, `SectionedFetchRequest` is not refreshed when changes are done to the fetched entity's attributes.
Hi, This issue started with iOS 18, in iOS 17 it worked correctly. I think there was a change in SectionedFetchRequest so maybe I missed it but it did work in iOS 17. I have a List that uses SectionedFetchRequest to show entries from CoreData. The setup is like this: struct ManageBooksView: View { @SectionedFetchRequest<Int16, MyBooks>( sectionIdentifier: \.groupType, sortDescriptors: [SortDescriptor(\.groupType), SortDescriptor(\.name)] ) private var books: SectionedFetchResults<Int16, MyBooks> var body: some View { NavigationStack { List { ForEach(books) { section in Section(header: Text(section.id)) { ForEach(section) { book in NavigationLink { EditView(book: book) } label: { Text(book.name) } } } } } .listStyle(.insetGrouped) } } } struct EditView: View { private var book: MyBooks init(book: MyBooks) { print("Init hit") self.book = book } } Test 1: So now when I change name of the Book entity inside the EditView and do save on the view context and go back, the custom EditView is correctly hit again. Test 2: If I do the same changes on a different attribute of the Book entity the custom init of EditView is not hit and it is stuck with the initial result from SectionedFetchResults. I also noticed that if I remove SortDescriptor(\.name) from the sortDescriptors and do Test 1, it not longer works even for name, so it looks like the only "observed" change is on the attributes inside sortDescriptors. Any suggestions will be helpful, thank you.
1
0
85
1d
iOS 18 Icon Display Inconsistency After App Update
Hello Apple Developer Community, I am encountering an issue with app icon rendering after updating an app on devices running iOS 18 or newer. Below are the details: Issue Summary: When updating an app from a previous version (with separate light and dark mode icons) to the latest version (where both modes use the same icon), the icon changes are not reflected consistently across all system menus. Steps to Reproduce: Set the device mode to Dark Mode. Install the previous app version (with different icons for light and dark modes). Update the app to the latest version (where both modes use the same icon). Change the device mode to Light Mode. Switch back to Dark Mode. Expected Behavior: The app icon should remain consistent across all system menus (Home Screen, Spotlight search, etc.) when switching between Light and Dark Modes. Observed Behavior: The app icon displays correctly on the Home Screen but inconsistencies appear in other menus, such as Spotlight search or when toggling between modes. For instance, in Dark Mode, the icon may revert to the previous black-colored logo or display incorrectly compared to the updated design. Additional Notes: The asset catalog is configured correctly, with identical icons set for both light and dark modes in the latest app version. Incrementing the build number was implemented during the update. A manual device restart resolves the issue on some devices, but not consistently. Questions for the Community: Has anyone else experienced similar app icon caching or rendering issues in iOS 18 or later? Are there known workarounds or specific configurations to ensure consistent icon rendering across all system menus? Could this be related to iOS 18's icon caching or appearance handling mechanisms? Your insights and suggestions would be greatly appreciated. Thank you for your time!
0
0
64
1d
NSInternalInconsistencyException Failed to create remote render context
Some crashes were found, not many, but we could not locate the specific code because the error stack is a systematic method. Error: NSInternalInconsistencyException Failed to create remote render context Stack: 0 CoreFoundation 0x000000018a879d78 ___exceptionPreprocess + 220 1 libobjc.A.dylib 0x00000001a34de734 _objc_exception_throw + 60 2 Foundation 0x000000018c0ff358 -[NSMutableDictionary(NSMutableDictionary) initWithContentsOfFile:] + 0 3 UIKitCore 0x000000018d475f8c ___UIKIT_DID_NOT_RECEIVE_A_REMOTE_CACONTEXT_FROM_COREANIMATION_INDICATING_A_POSSIBLE_BACKBOARDD_CRASH + 572 4 UIKitCore 0x000000018d232484 ___UIKIT_IS_REQUESTING_A_CACONTEXT_FROM_COREANIMATION + 80 5 UIKitCore 0x000000018d1fc32c +[_UIContextBinder createContextForBindable:withSubstrate:] + 708 6 UIKitCore 0x000000018d13bdec -[_UIContextBinder _contextForBindable:] + 148 7 UIKitCore 0x000000018cf5bd20 -[_UIContextBinder updateBindableOrderWithTest:force:] + 480 8 UIKitCore 0x000000018d2e1200 -[_UIContextBinder createContextsWithTest:creationAction:] + 92 9 UIKitCore 0x000000018ccd64c0 -[UIWindowScene _prepareForResume] + 156 10 UIKitCore 0x000000018ce2ef80 -[UIScene _emitSceneSettingsUpdateResponseForCompletion:afterSceneUpdateWork:] + 876 11 UIKitCore 0x000000018ce72528 -[UIScene scene:didUpdateWithDiff:transitionContext:completion:] + 288 12 UIKitCore 0x000000018cdfc8c8 -[UIApplicationSceneClientAgent scene:handleEvent:withCompletion:] + 476 13 FrontBoardServices 0x000000019c9dbe18 -[FBSScene updater:didUpdateSettings:withDiff:transitionContext:completion:] + 528 14 FrontBoardServices 0x000000019c9f413c ___94-[FBSWorkspaceScenesClient _queue_updateScene:withSettings:diff:transitionContext:completion:]_block_invoke_2 + 152 15 FrontBoardServices 0x000000019c9d9308 -[FBSWorkspace _calloutQueue_executeCalloutFromSource:withBlock:] + 240 16 FrontBoardServices 0x000000019c9df824 ___94-[FBSWorkspaceScenesClient _queue_updateScene:withSettings:diff:transitionContext:completion:]_block_invoke + 396 17 libdispatch.dylib 0x000000018a4e0a2c __dispatch_client_callout + 20 18 libdispatch.dylib 0x000000018a4e44e0 __dispatch_block_invoke_direct + 264 19 FrontBoardServices 0x000000019c9dac70 ___FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 48 20 FrontBoardServices 0x000000019c9da040 -[FBSSerialQueue _targetQueue_performNextIfPossible] + 220 21 FrontBoardServices 0x000000019c9de700 -[FBSSerialQueue _performNextFromRunLoopSource] + 28 22 CoreFoundation 0x000000018a89bf04 ___CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 28 23 CoreFoundation 0x000000018a8acc90 ___CFRunLoopDoSource0 + 208 24 CoreFoundation 0x000000018a7e6184 ___CFRunLoopDoSources0 + 268 25 CoreFoundation 0x000000018a7ebb4c ___CFRunLoopRun + 828 26 CoreFoundation 0x000000018a7ff6b8 _CFRunLoopRunSpecific + 600 27 GraphicsServices 0x00000001a6899374 _GSEventRunModal + 164 28 UIKitCore 0x000000018d164e88 -[UIApplication _run] + 1100 29 UIKitCore 0x000000018cee65ec _UIApplicationMain + 364 30 ??? 0x00000001059b9ce4 0x00000001059b9ce4 + 0 These crashes occurred when the App was about to enter the foreground. (UIApplicationWillEnterForegroundNotification) These crashes occurred on systems from 15 to 18. crash.log
1
0
51
1d
AVSpeechUtterance problem
I see this error in the debugger: #FactoryInstall Unable to query results, error: 5 IPCAUClient.cpp:129 IPCAUClient: bundle display name is nil Error in destroying pipe Error Domain=NSCocoaErrorDomain Code=4099 "The connection from pid 5476 on anonymousListener or serviceListener was invalidated from this process." UserInfo={NSDebugDescription=The connection from pid 5476 on anonymousListener or serviceListener was invalidated from this process.} on this function: func speakItem() { let utterance = AVSpeechUtterance(string: item.toString()) utterance.voice = AVSpeechSynthesisVoice(language: "en-GB") try? AVAudioSession.sharedInstance().setCategory(.playback) utterance.rate = 0.3 let synthesizer = AVSpeechSynthesizer() synthesizer.speak(utterance) } When running without the debugger, it will (usually) speak once, then it won't speak unless I tap the button that calls this function many times. I know AVSpeech has problems that Apple is long aware of, but I'm wondering if anyone has a work around. I was thinking there might be a way to call the destructor for AVSpeechUtterance and generate a new object each time speech is needed, but utterance.deinit() shows: "Deinitializers cannot be accessed"
0
0
68
1d
I am learning swift ui by mimicing stickies but i am facing richtexteditor problem
I am learning swift ui by mimicing stickies but i am having issue with richtextui Error ViewBridge to RemoteViewService Terminated: Error Domain=com.apple.ViewBridge Code=18 "(null)" UserInfo={com.apple.ViewBridge.error.hint=this process disconnected remote view controller -- benign unless unexpected, com.apple.ViewBridge.error.description=NSViewBridgeErrorCanceled} Why it is connecting to remote service when i develop it in local for mac UI error is this. I type cursor moves and no text displayed. changed color to everything some code import SwiftUI import AppKit struct RichTextEditor: NSViewRepresentable { @Binding var attributedText: NSAttributedString var isEditable: Bool = true var textColor: NSColor = .black var backgroundColor: NSColor = .white var font: NSFont = NSFont.systemFont(ofSize: 14) I only started swift ui 2 day ago. Bought mac mini 4 3 day ago to develop ios app but learning mac app first to get experience with mac environment Who can help Contact me via discord alexk3434 I need mac developer friends.
1
0
80
1d
QLPreviewController freezes when playing Videos
In my iOS App I present a QLPreviewController where I want to display a locally stored Video from the iPhone's document directory. let previewController = QLPreviewController() previewController.dataSource = self self.present(previewController, animated: true, completion: nil) func previewController(_ controller: QLPreviewController, previewItemAt index: Int) -> QLPreviewItem { let url = urlForPreview return url! as QLPreviewItem } This seems to work fine for all but one of my testflight users. He is using an iPhone 12 with iOS18.0.1. The screen becomes unresponsive. He cannot pause the video, share it or close the QLPreviewController. In his logfile I see the following error... [AVAssetTrack loadValuesAsynchronouslyForKeys:completionHandler:] invoked with unrecognized keys ( "currentVideoTrack.preferredTransform") Any ideas?.
0
0
75
2d