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
Posts under UI Frameworks topic

Post

Replies

Boosts

Views

Activity

CPMapTemplate measurement units on screen
I am wondering how I change the measurement units on screen in my CPMapTemplate. In my screenshot below the distance is in miles, but how can I change that to kilometers? Does this need to come from my route data? I am not seeing this anywhere in the CarPlay programming guide or in the documentation.
1
0
434
Jan ’25
How to drag drop to reorder items in a horizontal scroll view?
Hi, I thought that drag drop reorder should be very easy with SwiftUI, but apparently I was wrong (unless I'm missing something). It seems to me that SwiftUI's drag-drop reorder is only easy for List, which supports .onMove modifier. However, for UI like Grid, a horizontal ScrollView with items in a HStack, I don't see any easy approach to implement this. For example, ScrollView(.horizontal) { HStack { ForEach(items) { ItemView(item) } } } Does anyone know what's the best way to implement drag drop reorder for this horizontal scroll view?
4
0
589
Jan ’25
Download Rendered PDF
I need to render a PDF and then make it downloadable to the mobile device. I can generate the PDF but I'm unsure how to configure the download aspect. I have the following code: let renderer = UIGraphicsPDFRenderer(bounds: CGRect(x: 0, y: 0, width: 612, height: 792)) let pdf = renderer.pdfData { (context) in context.beginPage() let text = "Test" as NSString text.draw(in: CGRect(x: 0, y: 0, width: 100, height: 25))
4
0
758
Jan ’25
wrong value on the first buttonClick
When I run this code, and click on one of both 'currentZin' in the first screen that comes up with the view WordView, I see the content of the .preview value I used to initialize currentVerse (Verse= .preview) and not the values of the currentVerse that is in the Button action. When I leave the WordView-sheet and click again the WordView shows the good result. I looks that on the first click the currentVerse = verse in the Button is not executed. If Ido not initialize it, it has a nil value. Can Anyone explain what happens and how to solve it. struct HymnVerses: View { var hymn:Hymn @State private var currentZin: Int = 2 @State private var isLatin: Bool = true @State private var isMasked: Bool = false @State private var isTranslation: Bool = true @State private var currentSentence: String = "" @State private var showWordView: Bool = false @State private var currentVerse: Verse = .preview // Deze calculated property wordt op voorhand berekend. // Hierdoor blijft de referentie naar het origineel bestaan // wanneer ik currentVerse bereken. Daarvoor geraakte ik ze altijd kwijt. private var filteredVerses: [Verse] { hymn.verses.filter { $0.zin <= currentZin } } var body: some View { List { ForEach(filteredVerses) { verse in VStack(alignment: .leading) { Button { currentVerse = verse showWordView = true } label: { Text("\(verse.zin). \(currentSentence(for: verse))") .font(.headline) } } } .onAppear { currentVerse = filteredVerses.first! } }.sheet(isPresented: $showWordView, content: { WordView(vers: currentVerse, showWordView: $showWordView) }) .toolbar { ToolbarItem(placement: .bottomBar) { Button(isLatin ? "Dutch" : "Latin") { isLatin.toggle() } } ToolbarItem(placement: .bottomBar) { Button(isMasked ? "Unmask" : "Mask") { isMasked.toggle() } } ToolbarItem(placement: .bottomBar) { Button("Restart") { currentZin = 1 } } ToolbarItem(placement: .bottomBar) { Button("Next") { if currentZin < hymn.verses.count { currentZin += 1 } } } } } func maskLetters(in sentence: String, with mask: Character = "*") -> String { return sentence.map { char in if char.isLetter { return String(mask) } else { return String(char) } }.joined() } private func currentSentence(for verse: Verse) -> String { var temp: String { return isLatin ? verse.latijn : verse.nederlands } if isMasked { return maskLetters(in: temp) } else { return temp } } } #Preview { /// the navigationStack is nodig omdat anders de toolbar niet zichtbaar is met #Preview NavigationStack { let allTexts = AllTexts() HymnVerses(hymn: .preview).environment(allTexts) } }
3
0
206
Jan ’25
Bidirectional Text Rendering Issue in Swift UILabel for Arabic
I'm encountering an issue displaying a large HTML string (over 11470 characters) in a UILabel. Specifically, the Arabic text within the string is rendering left-to-right instead of the correct right-to-left direction. I've provided a truncated version of the HTML string and the relevant code snippet below. I've tried setting the UILabel's text alignment to right, but this didn't resolve the issue. Could you please advise on how to resolve this bidirectional text rendering problem? The results of the correct and incorrect approaches are shown in the image below. Here's the relevant Swift code: let labelView: UILabel = { let label = UILabel() label.textAlignment = .right label.translatesAutoresizingMaskIntoConstraints = false label.numberOfLines = 0 label.semanticContentAttribute = .forceRightToLeft label.backgroundColor = .white label.lineBreakMode = .byWordWrapping return label }() //Important!! //It must exceed 11470 characters. let htmlString = """ <p style=\"text-align: center;\"><strong>İSTİÂZE</strong></p> <p>Nahl sûresindeki:</p> <p dir="rtl" lang="ar"> فَاِذَا قَرَاْتَ الْقُرْاٰنَ فَاسْتَعِذْ بِاللّٰهِ مِنَ الشَّيْطَانِ الرَّج۪يمِ </p> <p><strong>“</strong><strong>Kur’an okuyacağın zaman kovulmuş şeytandan hemen Allah’a sığın!</strong><strong>”</strong> (Nahl 16/98) emri gereğince Kur’ân-ı Kerîm okumaya başlarken:</p> <p dir="rtl" lang="ar">اَعُوذُ بِاللّٰهِ مِنَ الشَّيْطَانِ الرَّج۪يمِ</p> <p><em>“Kovulmuş şeytandan Allah’a sığınırım” </em>deriz. Bu sözü söylemeye “istiâze<em>” denilir. “Eûzü”</em>, sığınırım, emân dilerim, yardım taleb ederim, gibi anlamlara gelir. It must exceed 11470 characters.</p> “”” if let data = htmlString.data(using: .utf8) { let options: [NSAttributedString.DocumentReadingOptionKey: Any] = [ .documentType: NSAttributedString.DocumentType.html, .characterEncoding: String.Encoding.utf8.rawValue ] do { let attributedString = try NSAttributedString(data: data, options: options, documentAttributes: nil) labelView.attributedText = attributedString } catch { print("HTML string işlenirken hata oluştu: \(error)") } } I'm using iOS 18.2 and Swift 6. Any suggestions on how to correct the bidirectional text rendering?
0
0
379
Jan ’25
How to Visualize Data in a DataFrame Using Charts
I want to visualize the data stored in a DataFrame using various charts (barmark, sectormark, linemark, etc.). My questions are as follows: Can a DataFrame be used directly within a chart? If so, could you provide a simple example? If it cannot be used directly, what is the correct way to use it? Could you provide an example? Thank you for your help. Best regards.
0
1
389
Jan ’25
QLPreviewingController can access previewed file, but cannot load files referenced by the previewed file
I have an app on the Mac App Store (so sandboxed) that includes a QuickLook Preview Extension that targets Markdown files. It established a QLPreviewingController instance for the macOS QuickLook system to access and it works. I'm in the process of updating it so that it displays inline images referenced in the file as well as styling the file's text. However, despite setting Downloads folder read-only access permission (and user-selected, though I know that shouldn't be required: no open/save dialogs here) in the extension's entitlements, Sandbox refuses too allow access to the test image: I always get a deny(1) file-read-data error in the log. FWIW, the test file is referenced in the source Markdown as an absolute unix file path. I've tried different signings and no joy. I’ve tried placing the referenced image in various other locations. Also no joy. All I can display is the error-case bundle image for 'missing image'. Question is, is this simply something that QuickLook extensions cannot do from within the sandbox, or am I missing something? Is there anything extra I can do to debug this?
0
0
408
Jan ’25
How to Maintain Background Color Consistency During ZoomTransitions in SwiftUI?
I’m currently working on a SwiftUI project and trying to implement a transition effect similar to ZoomTransitions. However, I’ve run into an issue. When transitioning from Page A to Page B using .navigationTransition(.zoom(sourceID: "world", in: animation)), Page A shrinks as expected, but its background color changes to the default white instead of the color I preset. I want the background color of Page A to remain consistent with my preset during the entire transition process. Here’s a simplified version of my code: Page A PartnerCard() .matchedTransitionSource(id: item.id, in: animation) Page B ``.navigationTransition(.zoom(sourceID: "world", in: animation))
Topic: UI Frameworks SubTopic: SwiftUI
0
0
282
Jan ’25
UIDocumentPickerViewController
I'm upgrading my app from minVersion iOS 11 to iOS 12. My compiler says that UIDocumentMenuViewController with UIDocumentPickerViewController is deprecated, they recommend to use directly the last one. So I change the code. fileprivate func openDocumentPicker() { let documentPicker = UIDocumentPickerViewController( documentTypes: [ "com.adobe.pdf", "org.openxmlformats.wordprocessingml.document", // DOCX "com.microsoft.word.doc" // DOC ], in: .import ) documentPicker.delegate = self view.window?.rootViewController?.present(documentPicker, animated: true, completion: nil) } When I open the picker in iOS 17.2 simulator and under it is well shown, like a page sheet. But in iOS 18.0 and up at first it opens like a page sheet with no content but then it is displayed as a transparent window with no content. Is there any issue with this component and iOS 18? If I open the picker through UIDocumentMenuViewControllerDelegate in an iphone with iOS 18.2 it is well shown. Image in iOS 18.2 with the snippet The same snippet in iOS 17.2 (and expected in older ones)
Topic: UI Frameworks SubTopic: UIKit Tags:
0
0
351
Jan ’25
EKCalendarChooser and Siri Suggestions
When using EKCalendarChooser it shows a list of calendars that the user can select, however it shows the Siri Suggestions calendar but theres no way to access it. Are supposed to be able to access the Siri Suggestions calendar as a regular EKCalendar? If yes is there a way to persist the selection (currently you can select the Siri Suggestions calendar [as shown in the image] but it doesn't have an actual id so it doesn't persist)? Also when getting EventStore.calendars(for: .event) it doesnt return an EKCalendar for Siri Suggestions, only for all the other calendars. This leads me to believe we can't access it, which in that case why is it shown on the EKCalendarChooser and there doesn't seem to be a way to hide it. Also is there a way to hide the AddCalendar Button in the bottom left?
1
0
352
Jan ’25
NSUIActivityDocumentMonitor throws a strange exception
This class is throwing an NSInternalInconsistencyException immediately after my app delegate gets an ApplicationWillResignActive message as shown below. This happens only on 15.2. In the Event processing run loop in my NSApplication subclass, I added a couple of lines to monitor the value of "mainWindow" as defined in NSApplication. It contains a valid window pointer until after the ApplicationWillResignActive message. FYI I do not appear to ever get a ApplicationDidResignActive call. My questions: What is NSUIActivityDocumentMonitor and what exactly does it do? I can find no documentation on it at all. Should I assume it is created by NSDocument? Can or should I prevent its creation? The error text implies that my NSApplication subclass is not sending out a notification when its "mainWindow" property changes (in my case it appears to get changed to nil as a result of resigning the active state). That has never been an issue before now. This does not occur on ANY other prior macOS releases including 15.1. How can I prevent this error that is being thrown by a previously unknown class? Are there new recommended actions I should take when I get the ApplicationWillResignActive call? Wouldn't NSApplication/NSObject handle the KVO compliance issue (notify observers of a change to "mainWindow")? FYI, this only happens when I have an opened document window (either new or opened from the desktop). If I ignore the error in my run loop, the app continues normally in the background and can be brought back to be the front app no problem. I'm at my wits end trying to get rid of this (properly instead of ignoring the error) and could use some guidance. This is a mature app in use by many clients. Objective C.
Topic: UI Frameworks SubTopic: AppKit
1
0
339
Jan ’25
What is the designated way to do custom background drawing in TextKit 2 when using UITextView/NSTextView?
In TextKit 1, I can override drawBackground(forGlyphRange:at:) in NSLayoutManager to do custom background drawing. However, I'm not too sure what the designated way of doing background drawing is in TextKit 2. One thing I've tried is to do custom drawing in my own CALayer that's used in the configureRenderingSurface delegate callback, but I'm unsure if we are suppose to use this API and steal the textViewportLayoutController.delegate away from _UITextLayoutcanvasView?
4
0
2.9k
Jan ’25
How to share 'back facing' iOS camera app at same time Eye Tracking app needs 'front facing' camera?
While using my xmas present of a new iPhone and iOS 18.2, I figured I'd try the Eye Tracker app. I've been working with clients successfully using Tobii and other existing eye trackers. In my limited tests, Apple has room for improvement. My main issue is with the camera app which cannot be used at the same time while using the Eye Tracker app. I get an error popup from Apple: Camera is use by another app The image below is from my app showing the popup message "Camera in use by another app", but the same error occurs on the installed camera app. This error is from Apple, not my app. For terminology: 'front' camera is the one pointing at the user (the selfi camera) while 'back' camera is the main one with multiple lenses. Eye tracking needs the 'front' camera. It seems when an app uses the camera, it takes over both the front and back facing cameras (since you might swap them). Thus another app, especially Eye Tracking, cannot use just the front facing camera at the same time. That limits use of Eye Tracking, in particular one cannot take pictures or click any buttons on an app that uses the camera. Anyone know of a way for an app to not take over both front and back cameras at the same time? If I can separate them, the Eye Tracker could use the front camera while the camera uses the back camera.
1
0
410
Jan ’25
CATransaction commit() crashed on background thread [EXC_BREAKPOINT: com.apple.root.****-qos.cooperative]
Problem Description We are developing a app for iOS and iPadOS that involves extensive custom drawing of paths, shapes, texts, etc. To improve drawing and rendering speed, we use CARenderer to generate cached images (CGImage) on a background thread. We adopted this approach based on this StackOverflow post: https://stackoverflow.com/a/75497329/9202699. However, we are experiencing frequent crashes in our production environment that we can hardly reproduce in our development environment. Despite months of debugging and seeking support from DTS and the Apple Feedback platform, we have not been able to fully resolve this issue. Our recent crash reports indicate that the crashes occur when calling CATransaction.commit(). We suspect that CATransaction may not be functioning properly outside the main thread. However, based on feedback from the Apple Feedback platform, we were advised to use CATransaction.begin() and CATransaction.commit() on a background thread. If anyone has any insights, we would greatly appreciate it. Code Sample The line CATransaction.commit() is causing the crash: [EXC_BREAKPOINT: com.apple.root.****-qos.cooperative] private let transactionLock = NSLock() // to ensure one transaction at a time private let device = MTLCreateSystemDefaultDevice()! @inline(never) static func drawOnCGImageWithCARenderer( layerRect: CGRect, itemsToDraw: [ItemsToDraw] ) -> CGImage? { // We have encapsulated everything related to CALayer and its // associated creations and manipulations within CATransaction // as suggested by engineers from Apple Feedback Portal. transactionLock.lock() CATransaction.begin() // Create the root layer. let layer = CALayer() layer.bounds = layerRect layer.masksToBounds = true // Add one sublayer for each item to draw itemsToDraw.forEach { item in // We have thousands or hundred thousands of drawing items to add. // Each drawing item may produce a CALayer, CAShapeLayer or CATextLayer. // This is also why we want to utilise CARenderer to leverage GPU rendering. layer.addSublayer( item.createCALayerOrCATextLayerOrCAShapeLayer() ) } // Create MTLTexture and CARenderer. let textureDescriptor = MTLTextureDescriptor.texture2DDescriptor( pixelFormat: .rgba8Unorm, width: Int(layer.frame.size.width), height: Int(layer.frame.size.height), mipmapped: false ) textureDescriptor.usage = [MTLTextureUsage.shaderRead, .shaderWrite, .renderTarget] let texture = device.makeTexture(descriptor: textureDescriptor)! let renderer = CARenderer(mtlTexture: texture) renderer.bounds = layer.frame renderer.layer = layer.self /* ********************************************************* */ // From our crash report, this is where the crash happens. CATransaction.commit() /* ********************************************************* */ transactionLock.unlock() // Rendering layers onto MTLTexture using CARenderer. renderer.beginFrame(atTime: 0, timeStamp: nil) renderer.render() renderer.endFrame() // Draw MTLTexture onto image. guard let colorSpace = CGColorSpace(name: CGColorSpace.sRGB), let ciImage = CIImage(mtlTexture: texture, options: [.colorSpace: colorSpace]) else { return nil } // Convert CIImage to CGImage. let context = CIContext() return context.createCGImage(ciImage, from: ciImage.extent) }
0
1
479
Jan ’25
Differences between SwiftUI in Monterey and Sequoia
Having written a SwiftUI based app on macOS 15.2 with Xcode 16.2 I built a version for Monterey (which required backing off some modern uses, like #Preview and others). But the SwiftUI layout, positioning and dimensions, didn't use anything new so, I was surprised that the app did not look exactly the same on Monterey. It was not wildly different, but enough that I had to modify several to frame, padding and font parameters in order to restore my desired appearance. I'm assuming that over the course of generations of SwiftUI, things change -- that's life, but this was a frustrating process for at least two reasons: view modifiers can't be conditionally compiled so something like this, for example, isn't possible RoundedRectangle(cornerRadius: 1) <if Monterey> .padding(.horizontal, -2.0) <else> .padding(.horizontal, -4.0) <endif> .frame(height: 4.0) previewing views is a challenge. Previewing on Sequoia doesn't show what the views will look like on Monterey. I can build the app on Monterey and use the non-macro #preview mechanism, but in order to do that, and the above, I'm pushed to maintain two versions of my app because the following doesn't compile: #if swift(>=5.9) #Preview("Monitor") { MonitorView() } #else struct MonitorView_Previews: PreviewProvider { static var previews: some View { MonitorView() } } #endif These are not show-stoppers but I do wonder if I'm missing some mechanism(s) to ease the pain, or if SwiftUI functional changes are documented.
Topic: UI Frameworks SubTopic: SwiftUI
2
0
342
Jan ’25
Crash using NSMutableAttributedString with an HMTL document inside a collection view - iOS 18, XCode 16
We're attempting to upgrade to XCode 16 but are encountering a consistent crash when doing so. The actual exception message comes from the UICollectionView, with this message and stack trace. *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Expected dequeued view to be returned to the collection view in preparation for display. When the collection view's data source is asked to provide a view for a given index path, ensure that a single view is dequeued and returned to the collection view. Avoid dequeuing views without a request from the collection view. For retrieving an existing view in the collection view, use -[UICollectionView cellForItemAtIndexPath:] or -[UICollectionView supplementaryViewForElementKind:atIndexPath:]. Dequeued view: <Redacted: 0x17831f080; baseClass = UICollectionViewCell; frame = (16 923.667; 408 450); layer = <CALayer: 0x6000004ad680>>; Collection view: <UICollectionView: 0x10ca67000; frame = (0 0; 440 809.667); clipsToBounds = YES; gestureRecognizers = <NSArray: 0x600000d41e60>; backgroundColor = <UIDynamicProviderColor: 0x600000285640; provider = <__NSMallocBlock__: 0x600000c7aac0>>; layer = <CALayer: 0x600000322400>; contentOffset: {0, 139.66666666666666}; contentSize: {440, 3247.625}; adjustedContentInset: {0, 0, 34, 0}; layout: <UICollectionViewCompositionalLayout: 0x15a8732a0>; dataSource: <_TtGC5UIKit34UICollectionViewDiffableDataSourceOC8Redacted_: 0x60000000ead0>>' *** First throw call stack: ( 0 CoreFoundation 0x00000001804b910c __exceptionPreprocess + 172 1 libobjc.A.dylib 0x0000000180092da8 objc_exception_throw + 72 2 Foundation 0x0000000180e67c70 _userInfoForFileAndLine + 0 3 UIKitCore 0x00000001852348a4 __43-[UICollectionView _updateVisibleCellsNow:]_block_invoke.445 + 136 4 UIKitCore 0x0000000185b2a42c -[_UICollectionViewSubviewManager removeAllDequeuedViewsWithEnumerator:] + 188 5 UIKitCore 0x000000018523436c -[UICollectionView _updateVisibleCellsNow:] + 4000 6 UIKitCore 0x0000000185234288 -[UICollectionView _updateVisibleCellsNow:] + 3772 7 UIKitCore 0x0000000185239174 -[UICollectionView layoutSubviews] + 284 8 UIKitCore 0x00000001860a3418 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 2404 9 QuartzCore 0x000000018b335624 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 432 10 QuartzCore 0x000000018b3403f8 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 124 11 QuartzCore 0x000000018b272430 _ZN2CA7Context18commit_transactionEPNS_11TransactionEdPd + 464 12 QuartzCore 0x000000018b2a0c70 _ZN2CA11Transaction6commitEv + 652 13 QuartzCore 0x000000018b2a21c4 _ZN2CA11Transaction25flush_as_runloop_observerEb + 68 14 UIKitCore 0x0000000185b302fc _UIApplicationFlushCATransaction + 48 15 UIKitCore 0x0000000185a60eb4 __setupUpdateSequence_block_invoke_2 + 352 16 UIKitCore 0x00000001850a5cec _UIUpdateSequenceRun + 76 17 UIKitCore 0x0000000185a60858 schedulerStepScheduledMainSection + 168 18 UIKitCore 0x0000000185a5fc90 runloopSourceCallback + 80 19 CoreFoundation 0x000000018041d294 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24 20 CoreFoundation 0x000000018041d1dc __CFRunLoopDoSource0 + 172 21 CoreFoundation 0x000000018041c99c __CFRunLoopDoSources0 + 324 22 CoreFoundation 0x0000000180416e84 __CFRunLoopRun + 788 23 CoreFoundation 0x00000001804166f4 CFRunLoopRunSpecific + 552 24 UIFoundation 0x0000000184c5c0c0 -[NSHTMLReader _loadUsingWebKit] + 1416 25 UIFoundation 0x0000000184c5cbe8 -[NSHTMLReader attributedString] + 20 26 UIFoundation 0x0000000184bdc3c8 _NSReadAttributedStringFromURLOrDataCommon + 2760 27 UIFoundation 0x0000000184bd82d4 _NSReadAttributedStringFromURLOrData + 180 28 UIFoundation 0x0000000184bd81b8 -[NSAttributedString(NSAttributedStringUIFoundationAdditions) initWithData:options:documentAttributes:error:] + 144 29 Redacted.debug.dylib 0x000000010f53b6d0 $sSo25NSMutableAttributedStringC4data7options18documentAttributesAB10Foundation4DataV_SDySo012NSAttributedC24DocumentReadingOptionKeyaypGSAySo12NSDictionaryCSgGSgtKcfcTO + 204 30 Redacted.debug.dylib 0x000000010f53a984 $sSo25NSMutableAttributedStringC4data7options18documentAttributesAB10Foundation4DataV_SDySo012NSAttributedC24DocumentReadingOptionKeyaypGSAySo12NSDictionaryCSgGSgtKcfC + 76 31 Redacted.debug.dylib 0x000000010f53a860 $sSS8RedactedE20htmlAttributedStringSo09NSMutablecD0CSgyF + 572 32 Redacted.debug.dylib 0x000000010fbddf54 $s8Redacted + 132 33 Redacted.debug.dylib 0x000000010fbde71c $s8Redacted + 196 34 Redacted.dylib 0x000000010f75b1d0 $s8Redacted + 544 35 Redacted.dylib 0x000000010f2ca174 $s8Redacted + 2052 36 Redacted.debug.dylib 0x000000010e7e6884 $s8Redacted 37 Redacted.debug.dylib 0x000000010e7de9f0 $s8Redacted + 2376 38 Redacted.debug.dylib 0x000000010f336820 $s8Redacted 39 UIKitCore 0x0000000184f0c3e8 block_destroy_helper.22 + 18032 40 UIKitCore 0x0000000184f109a4 block_destroy_helper + 11080 41 UIKitCore 0x0000000184f0e810 block_destroy_helper + 2484 42 UIKitCore 0x00000001851aa8f0 -[__UIDiffableDataSource collectionView:cellForItemAtIndexPath:] + 136 libc++abi: terminating due to uncaught exception of type NSException The collection view cell being dequed contains a string that is created from HTML content with NSMutableAttributedString This line is where execution stop data: data, options: [.documentType: NSAttributedString.DocumentType.html], documentAttributes: nil ) This code has worked fine for years but now inexplicably is crashing. I've seen various similiar posts related to iOS 18 but none with a resolution
Topic: UI Frameworks SubTopic: UIKit Tags:
3
2
916
Jan ’25
Displaying a toast on successful operation in CarPlay
Hello, Please guide me if there is a way to show a simple toast to a user that the action has been performed. When a user taps on a button, an api returns a status based on which I need to show appropriate message as a toast. Is this possible in CarPlay? If not, why? Please suggest any alternative for this. Awaiting your response Thanks a lot!!
1
0
474
Jan ’25
Unrealistically high snowfall amounts being reported by WeatherKit
I filed FB16332997 about the VERY high snowfall estimates I'm seeing in WeatherKit and iOS Weather. I initially thought something was wrong with my weather app but I verified the numbers with the iOS Weather app and another third party weather app. For Atlanta last week it was saying 7.5" when it ended up being 2" (which I can live with). Two days ago it reported there could be 16" of snow in northern Florida. That's impossible! This morning it was reporting that Niceville could have 6-7" of snow, which would be significantly more than highest amount in recorded history for Florida (where snow is extremely rare). It almost makes me wonder if the liquid precipitation value is actually the snowfall amount in reality. And then that is incorrectly being converted to the snowfall amount.
2
0
427
Jan ’25
https://developer.apple.com/documentation/swiftui/tab/init(value:content:label:)
As per the documentation link, the Tab initializer in SwiftUI should allow supplying a custom view to the Label. However, the colors used within the Label view are not being honored as expected. I attempted to set custom colors in the Label, but they either default to system-defined styles or are ignored entirely. This behavior does not align with my understanding of how custom views should work in SwiftUI's Label. Am I missing a step or configuration here, or is this a bug in the current implementation? struct ContentView: View { @State private var activeTab: TabItem = .homeTab var body: some View { TabView(selection: $activeTab) { ForEach(TabItem.allCases) { tabItem in Tab(value: tabItem) { getView(for: tabItem) } label: { VStack(spacing: 0) { MainTabButtonView( selected: activeTab == tabItem, tabItem: tabItem ) Text(tabItem.title) } } } } } } private extension ContentView { @ViewBuilder func getView(for tabItem: TabItem) -> some View { switch tabItem { case .homeTab: Text("Home") case .searchTab: Text("Search") case .profileTab: Text("Profile") case .moreTab: Text("More") } } } #Preview { ContentView() } enum TabItem: String, Identifiable, Hashable, CaseIterable { case homeTab case searchTab case profileTab case moreTab var tabImage: String { switch self { case .homeTab: "house" case .searchTab: "magnifying-glass" case .profileTab: "biographic" case .moreTab: "hamburger-menu" } } var title: String { switch self { case .homeTab: "Home" case .searchTab: "Search" case .profileTab: "Profile" case .moreTab: "More" } } var id: String { rawValue } } struct MainTabButtonView: View { private let selected: Bool private let tabItem: TabItem init( selected: Bool, tabItem: TabItem ) { self.selected = selected self.tabItem = tabItem } var body: some View { Image(tabItem.tabImage) .renderingMode(.template) .resizable() .aspectRatio(contentMode: .fill) .frame(width: 30, height: 30) .foregroundStyle( selected ? Color.green : Color.orange ) } } Expected Behavior: The custom colors applied within the Label should render as defined. Actual Behavior: The colors are overridden or ignored, defaulting to the system-defined styles. Environment: Xcode Version: Xcode 16.2 iOS: 18.2 Swift Version: Swift 6
2
0
344
Jan ’25