Construct and manage graphical, event-driven user interfaces for iOS or tvOS apps using UIKit.

Posts under UIKit tag

200 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

QLPreviewController gets frozen after drawing in iOS17
There seem to be a regression in QLPreviewController with iOS17, since it works in both iOS16(latest) and iOS18b3. After following the steps (described below), using iOS17.X the QLPreviewController gets frozen up so all of it's top buttons are no tappable, although you can still draw on the canvas. Steps to reproduce: Setup QLPreviewController to preview a single image in png format. The QLPreviewController should be presented as the rootViewController of a UINavigationController. Present the UINavigationController that has the QLPreviewController as its rootViewController. Tap the Markup button. Pick the leftest tool from the PencilKit tools at the bottom. Draw a curvy long line from the bottom-right corner of the canvas, to the top-left corner of the canvas. Tap any of the top buttons. Current: The top buttons are not tappable. Expected: The top buttons are tappable. Any idea how to workaround/fix this issue? Notes: The issue seems to be reproducible in iOS17, and isn't reproducible in iOS16 or iOS18b3 using Xcode 15.4 and Xcode 16b3. The issue is reproducible in both iOS17 Simulator or devices. The issue is reproducible in both UIKit and SwiftUI. Possible same issue was mentioned here: https://stackoverflow.com/questions/78090416/navigation-toolbar-buttons-stop-working-after-keyboard-is-shown-on-ios-17-sw I couldn't attach a sample project to here due to file format limitation, but you can use the project from this repository and use a png instead of a pdf: https://github.com/NilCoalescing/SwiftUI-Code-Examples/tree/main/QuickLook/SwiftUIQuickLookInUINavigationController (code by Natalia Panferova) Attached is the image of the drawing done in iOS17.5 Simulator.
3
2
679
Aug ’24
iOS18 and iOS16.5.0 pushViewController crashed,But it looks like UIFont crashed,Can someone analyze that?
Exception Type: EXC_BAD_ACCESS (SIGBUS) Exception Subtype: KERN_PROTECTION_FAILURE at 0x0000000205fc4a04 Exception Codes: 0x0000000000000002, 0x0000000205fc4a04 VM Region Info: 0x205fc4a04 is in 0x205fb2cd0-0x205ff9d60; bytes after start: 73012 bytes before end: 217947 REGION TYPE START - END [ VSIZE] PRT/MAX SHRMOD REGION DETAIL __DATA_CONST 205fad9c0-205fb2cd0 [ 21K] r--/rw- SM=COW .../DMCUtilities ---> unused __TEXT 205fb2cd0-205ff9d60 [ 284K] r--/rw- SM=COW ...ed lib __TEXT __DATA_CONST 205ff9d60-2060070a0 [ 53K] r--/rw- SM=COW ...lCoordination Termination Reason: SIGNAL 10 Bus error: 10 Terminating Process: exc handler [1039] Triggered by Thread: 0 Thread 0 Crashed: 0 ??? 0x0000000205fc4a04 0x0 + 8690354692 1 libsystem_pthread.dylib 0x000000021608c2fc __pthread_once_handler + 76 (pthread.c:1924) 2 libsystem_platform.dylib 0x0000000215ff2940 _os_once_callout + 32 (lock.c:1180) 3 libsystem_pthread.dylib 0x0000000216088f68 pthread_once + 100 (pthread.c:1934) 4 libFontParser.dylib 0x00000001ddd59648 TFont::CreateFontEntitiesForFile(char const*, timespec, bool, short, char const*) + 96 (Font.cpp:814) 5 libFontParser.dylib 0x00000001ddce0908 FPFontCreateFontsWithPath + 252 (FontParser.cpp:2601) 6 CoreGraphics 0x00000001b7df77f8 create_private_data_array_with_path + 20 (xt-vtable.c:109) 7 CoreGraphics 0x00000001b7dd0f30 CGFontCreateFontsWithPath + 40 (CGFontCreate.c:501) 8 CoreGraphics 0x00000001b7da76c0 CGFontCreateFontsWithURL + 672 (CGFontURL.c:315) 9 libGSFont.dylib 0x00000001d001e0b8 AddFontsFromURLOrPath + 240 (GSFont.m:996) 10 libGSFont.dylib 0x00000001d0018d1c __Initialize_block_invoke + 1404 (GSFont.m:1478) 11 libdispatch.dylib 0x00000001bd7a2eac _dispatch_client_callout + 20 (object.m:560) 12 libdispatch.dylib 0x00000001bd7a46ec _dispatch_once_callout + 32 (once.c:52) 13 libGSFont.dylib 0x00000001d0019080 Initialize + 212 (GSFont.m:1352) 14 libdispatch.dylib 0x00000001bd7a2eac _dispatch_client_callout + 20 (object.m:560) 15 libdispatch.dylib 0x00000001bd7a46ec _dispatch_once_callout + 32 (once.c:52) 16 libdispatch.dylib 0x00000001bd7a2eac _dispatch_client_callout + 20 (object.m:560) 17 libdispatch.dylib 0x00000001bd7a46ec _dispatch_once_callout + 32 (once.c:52) 18 CoreText 0x00000001b7b803c4 TDescriptorSource::TDescriptorSource() + 196 (TDescriptorSource.cpp:150) 19 CoreText 0x00000001b7b8e524 CTFontDescriptorCreateForUIType + 48 (CTFontDescriptor.cpp:571) 20 CoreText 0x00000001b7b8e240 CTFontCreateUIFontForLanguage + 20 (CTFont.cpp:181) 21 UIFoundation 0x00000001c06bdbc0 UINewFont + 840 (UIFont.m:247) 22 UIFoundation 0x00000001c06bd474 +[UIFont systemFontOfSize:traits:] + 44 (UIFont.m:1020) 23 UIKitCore 0x00000001b863265c -[_UITextAttributeDefaultCategories _genericDefaults:] + 96 (_UITextAttributeDefaults.m:98) 24 UIKitCore 0x00000001b8632534 -[_UITextAttributeDefaultCategories initWithUserInterfaceIdiom:] + 208 (_UITextAttributeDefaults.m:80) 25 UIKitCore 0x00000001b8632440 __48+[_UITextAttributeDefaults _unspecifiedDefaults]_block_invoke + 32 (_UITextAttributeDefaults.m:192) 26 libdispatch.dylib 0x00000001bd7a2eac _dispatch_client_callout + 20 (object.m:560) 27 libdispatch.dylib 0x00000001bd7a46ec _dispatch_once_callout + 32 (once.c:52) 28 UIKitCore 0x00000001b83b2044 +[_UITextAttributeDefaults _unspecifiedDefaults] + 80 (_UITextAttributeDefaults.m:191) 29 UIKitCore 0x00000001b83b1f3c +[UILabel defaultFont] + 88 (UILabel.m:660) 30 UIKitCore 0x00000001b849a020 __22-[UILabel _commonInit]_block_invoke_2 + 44 (UILabel.m:1349) 31 UIKitCore 0x00000001b83d45b0 +[UIView _performSystemAppearanceModifications:] + 72 (UIView.m:3759) 32 UIKitCore 0x00000001b83d4060 -[UILabel _commonInit] + 352 (UILabel.m:1359) 33 UIKitCore 0x00000001b83d3e18 -[UILabel initWithFrame:] + 56 (UILabel.m:1433) 34 UIKitCore 0x00000001b8521570 _UINavigationBarLargeTitleViewNewLabel + 28 (_UINavigationBarLargeTitleViewLayout.m:29) 35 UIKitCore 0x00000001b85bc7ec -[_UINavigationBarLargeTitleViewLayout initWithContentView:] + 76 (_UINavigationBarLargeTitleViewLayout.m:55) 36 UIKitCore 0x00000001b84869a0 -[_UINavigationBarLargeTitleView initWithFrame:] + 64 (_UINavigationBarLargeTitleView.m:61) 37 UIKitCore 0x00000001b8485fc4 -[_UINavigationBarVisualProviderModernIOS prepare] + 604 (_UINavigationBarVisualProviderModernIOS.m:246) 38 UIKitCore 0x00000001b8485ccc -[UINavigationBar _commonNavBarInit] + 188 (UINavigationBar.m:1444) 39 UIKitCore 0x00000001b84859a8 -[UINavigationBar initWithFrame:] + 160 (UINavigationBar.m:1495) 40 UIKitCore 0x00000001b835ab70 -[UINavigationController _navigationBarHiddenByDefault:] + 80 (UINavigationController.m:2513) 41 UIKitCore 0x00000001b835d014 -[UINavigationController loadView] + 168 (UINavigationController.m:4252) 42 UIKitCore 0x00000001b835c6a8 -[UIViewController loadViewIfRequired] + 100 (UIViewController.m:4235) 43 UIKitCore 0x00000001b835c624 -[UIViewController view] + 24 (UIViewController.m:4299) 44 UIKitCore 0x00000001b84f3524 -[UINavigationController pushViewController:transition:forceImmediate:] + 404 (UINavigationController.m:8388) 45 UIKitCore 0x00000001b84f335c -[UINavigationController pushViewController:animated:] + 628 46 DUMovie 0x0000000104e19058 -[DUNavigationController pushViewController:animated:] + 1212 (DUNavigationController:324) 47 UIKitCore 0x00000001b84e41a0 -[UINavigationController initWithRootViewController:] + 152 (UINavigationController.m:609) (UINavigationController.m:8304)
2
0
764
Jul ’24
imageData property of CNContact
After setting the imageData property of CNContact through the API, I can see in the address book that the contact's avatar has been set to the imageData image, But when my phone version is iOS 17.1.0, when this contact calls in and locks the screen, I can see that this image is displayed in full screen, But when my phone version is iOS 17.5.1, when this contact calls in, the screen is locked and the image can only be displayed on the avatar, with a blurred image in the background, After iOS 17, contacts can set their avatars and posters separately in their contact list. How can I set these two images through code, just like setting the imageData property of CNContact through API. I see that there is a parameter in the CNContact property called _fullscreenImageData, but there is no value inside, and I am unable to obtain data for this parameter. I don't know how to manipulate this data in order to achieve the effect of setting up posters in the iOS 17.5.1 system.
1
0
338
Jul ’24
How to show overlay on top of all other APP
I'm trying to display overlay on screen by following code: NSRect windowRect = [[NSScreen mainScreen] frame]; self.overlayWindow = [[NSWindow alloc] initWithContentRect:windowRect styleMask:NSWindowStyleMaskBorderless backing:NSBackingStoreBuffered defer:NO screen:[NSScreen mainScreen]]; [self.overlayWindow setReleasedWhenClosed:YES]; [self.overlayWindow setBackgroundColor:[NSColor colorWithCalibratedRed:0.0 green:1.0 blue:0.0 alpha:0.1]]; [self.overlayWindow setAlphaValue:1.0]; [self.overlayWindow setOpaque:NO]; [self.overlayWindow setIgnoresMouseEvents:NO]; [self.overlayWindow makeKeyAndOrderFront:nil]; self.overlayWindow.ignoresMouseEvents = YES; self.overlayWindow.level = NSScreenSaverWindowLevel; self.overlayWindow.collectionBehavior = NSWindowCollectionBehaviorCanJoinAllSpaces | NSWindowCollectionBehaviorCanJoinAllApplications; But when other APP enter full screen, the overlay disappears even I set the collectionBehavior with option NSWindowCollectionBehaviorCanJoinAllApplications. Is it possible to display a overlay on top of all other APPs?
0
0
315
Jul ’24
Tapping once with both hands only works sometimes in visionOS
Hello! I have an iOS app where I am looking into support for visionOS. I have a whole bunch of gestures set up using UIGestureRecognizer and so far most of them work great in visionOS! But I do see something odd that I am not sure can be fixed on my end. I have a UITapGestureRecognizer which is set up with numberOfTouchesRequired = 2 which I am assuming translates in visionOS to when you tap your thumb and index finger on both hands. When I tap with both hands sometimes this tap gesture gets kicked off and other times it doesn't and it says it only received one touch when it should be two. Interestingly, I see this behavior in Apple Maps where tapping once with both hands should zoom out the map, which only works sometimes. Can anyone explain this or am I missing something?
5
0
433
Jul ’24
The watchOS support of NSValue.CGSizeValue
Starting from Xcode 16 Beta 2, NSValue.CGSizeValue is no longer available on watchOS, whereas this method was supported in previous versions of Xcode. The Xcode header files mark this method as unavailable on watchOS, but after manually modifying the Xcode files to remove the unavailable macro, the code compiles and runs normally. Is there a change in this API that makes it unsupported on watchOS, or is this an error? Previously, I submitted feedback FB14072192, and the status of this feedback was updated to "Unable to diagnose with current information" without any further response. If this is indeed an issue, I hope it can be fixed.
2
1
532
Jul ’24
Prevent Large Title from Moving Down when Refreshing TableView
I have implemented the Large Title for UITableView correctly. The Navigation bar collapses when scrolling down the table view. However, when pulling to refresh, the Large Title moves down the screen instead of staying stationary. I suspect that this is the default behavior. Is there a way to keep the large title stationary when pulling downward to refresh the UITableView?
0
0
422
Jul ’24
Poor App Store/TestFlight Build Scrolling Performance
We are experiencing a particularly niche issue where the scrolling performance for one of our table/collection views severely lags, but only for App Store and TestFlight builds. For all local builds and the internal builds we create for our QE team, the scrolling performance is smooth and free of any issues. It's only when the app is distributed through TestFlight or the App Store do we see this issue. We've gone over the build settings a number of times and have practically ruled out any differences between local builds, builds provided to QE, and builds that are uploaded to the App Store/TestFlight. All builds are effectively identical. We have tried to reproduce this issue locally, but to no avail. We're not able to take an App Store or TestFlight build and profile or debug it locally, so we're pretty much at a loss in terms of how to proceed and resolve this issue. Is this an issue that's been encountered before? Any advice on how to proceed?
0
1
384
Jul ’24
QLPreviewController with SwiftUI
I'm having a problem where any buttons won't be shown when displaying a QLPreviewController with swift. With .quickLookPreview() these buttons are shown, including share, done, annotation etcetera. The buttons are not shown when using QLPreviewController with SwiftUI, however if used with other UIKit they are shown. How to fix this? I'm not really looking forward in implementing all of the annotation functions and other QuickLook capabilities again. The ultimate goal of mine is to allow annotation and other pdf editing with the ability to save the file via the Done button, but on .quickLookPreview() the Done button displays "Save to files" and "Discard" and on QLPreviewController the button is not shown. The issue has been addressed on several forums, yet a solution has not been found. Reproducement in nutshell: new QLPreviewController conforming to UIViewControllerRepresentable display the QLPreviewController in SwiftUI view Thanks.
2
0
772
Jul ’24
Custom Width of sheet in landscape [UiKit]
I am using UISheetPresentationController to present a sheet. Everything works fine except I am not able to modify width of the sheet in landscape mode. As per design the width has to be 60% of the view bounds. In Apple talk: https://developer.apple.com/videos/play/wwdc2021/10063/ It is mentioned that we can resize sheet to preferredContentSize if this flag is set to true: sheet.widthFollowsPreferredContentSizeWhenEdgeAttached = true But this does not work. Here is my code: class BottomSheetController<Content: View>: UIViewController { private var hostingController: UIHostingController<Content>? init( content: @escaping () -> Content) { self.hostingController = UIHostingController(rootView: content()) super.init(nibName: nil, bundle: nil) configureSheetProperties() } required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") } override func viewDidLoad() { super.viewDidLoad() guard let hostingController = hostingController else { return } addChild(hostingController) view.addSubview(hostingController.view) hostingController.didMove(toParent: self) hostingController.view.translatesAutoresizingMaskIntoConstraints = false NSLayoutConstraint.activate([ hostingController.view.topAnchor.constraint(equalTo: view.topAnchor), hostingController.view.leadingAnchor.constraint(equalTo: view.leadingAnchor), hostingController.view.trailingAnchor.constraint(equalTo: view.trailingAnchor), hostingController.view.bottomAnchor.constraint(equalTo: view.bottomAnchor), ]) } private func configureSheetProperties() { modalPresentationStyle = .pageSheet preferredContentSize = CGSize(width: view.bounds.width * 0.6, height: view.bounds.height) if let sheet = sheetPresentationController { sheet.prefersGrabberVisible = true sheet.prefersScrollingExpandsWhenScrolledToEdge = false sheet.prefersEdgeAttachedInCompactHeight = true sheet.widthFollowsPreferredContentSizeWhenEdgeAttached = true sheet.preferredCornerRadius = 20 sheet.detents = [.medium()] } } open override var preferredContentSize: CGSize { get { return CGSize(width: view.bounds.width * 0.6, height: super.preferredContentSize.height) } set { super.preferredContentSize = CGSize(width: view.bounds.width * 0.6, height: newValue.height) } } }
1
0
305
Jul ’24
AVPlayerViewController (AppleTV) - Dolby (multi-channel audio) visualisation
We noticed that AVPlayerViewController does not always show the "Multi-channel" label in the audio setting in the player when playing a video asset with surround sound as an audio track. (see image) We only serve in the HLS master manifest a multichannel audio track, like this #EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="audio_0",CHANNELS="6",NAME="Surround",LANGUAGE.... Different tvOS versions will give us different outcomes on whether or not the "multi-channel" label is shown DOES NOT SHOW (the label Multi-channel will not show) Model A1842 (tvOS v 17.5.1) Model A1625 (tvOS v 16.6) DOES SHOW (see image) Model A1625 (tvOS v 15.6) This gives us the impression that the label being shown depends on tvOS version.. Any reason why? This is an ideal way for the user to see that the audio track has surround..
0
1
494
Jul ’24
UITableViewDiffableDataSource apply snapshot crashes on iOS 17
Hello all, We got app crashes on dataSource.apply(snapshot, animatingDifferences: false) after refactoring our tableView code to UITableViewDiffableDataSource. This doesn't happen every time. DispatchQueue.main.async { [weak self] in guard let self = self else { return } var snapshot = getCurrentSnapshot() snapshot.deleteItems([...]) snapshot.appendItems([...], toSection: section) dataSource.apply(snapshot, animatingDifferences: false) } And the controller has deallocated before it. Crash log: controller (0x110a64800): deallocated *** Assertion failure in NSInteger _UITableViewRowDataNumberOfRowsInSection(UITableViewRowData *__unsafe_unretained, NSInteger)(), UITableViewRowData.m:1761 *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Requested the number of rows for section (4) which is out of bounds.' *** First throw call stack: ( 0 CoreFoundation 0x0000000180491128 __exceptionPreprocess + 172 1 libobjc.A.dylib 0x000000018008412c objc_exception_throw + 56 2 Foundation 0x0000000180d11770 -[NSMutableDictionary(NSMutableDictionary) classForCoder] + 0 3 UIKitCore 0x0000000185538ad0 -[UITableViewRowData numberOfRowsInSection:] + 260 4 UIKitCore 0x00000001855052f0 -[UITableView _shouldDrawSeparatorAtBottomOfSectionForCellAtIndexPath:] + 152 5 UIKitCore 0x0000000185504dbc -[UITableView _updateSeparatorStateForCell:atIndexPath:] + 100 6 UIKitCore 0x0000000185504cf0 -[UITableView _updateSeparatorStateForVisibleCells] + 188 7 UIKitCore 0x00000001854f4bd0 -[UITableView _updateAnimationDidStopWithOldVisibleViews:finished:context:] + 1108 8 UIKitCore 0x00000001854f2630 __46-[UITableView _updateWithItems:updateSupport:]_block_invoke_4 + 36 9 UIKitCore 0x00000001857fcb1c __UIVIEW_IS_EXECUTING_ANIMATION_COMPLETION_BLOCK__ + 28 10 UIKitCore 0x00000001857fce24 -[UIViewAnimationBlockDelegate _sendDeferredCompletion:] + 100 11 libdispatch.dylib 0x000000010e5100f0 _dispatch_call_block_and_release + 24 12 libdispatch.dylib 0x000000010e51193c _dispatch_client_callout + 16 13 libdispatch.dylib 0x000000010e5215e4 _dispatch_main_queue_drain + 1228 14 libdispatch.dylib 0x000000010e521108 _dispatch_main_queue_callback_4CF + 40 15 CoreFoundation 0x00000001803f1a30 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12 16 CoreFoundation 0x00000001803ec148 __CFRunLoopRun + 1936 17 CoreFoundation 0x00000001803eb5a4 CFRunLoopRunSpecific + 572 18 GraphicsServices 0x000000018e9fbae4 GSEventRunModal + 160 19 UIKitCore 0x00000001852f02e4 -[UIApplication _run] + 868 20 UIKitCore 0x00000001852f3f5c UIApplicationMain + 124 21 appName 0x0000000103e8b0dc $s22appNameySpySpys4Int8VGGXEfU_ + 192 22 appName 0x0000000103e8b480 _swift_se0333_UnsafeMutablePointer_withMemoryRebound + 900 23 appName 0x0000000103e8af30 main + 1320 24 dyld 0x000000010e409544 start_sim + 20 25 ??? 0x000000010e61a0e0 0x0 + 4536246496 26 ??? 0xca54000000000000 0x0 + 14579277893705138176 ) libc++abi: terminating due to uncaught exception of type NSException
2
0
415
Jul ’24
UIRefresh not working for my project?
So for my project it's a SwiftUI Project however if I Add '@objc' to expose this instance method to Objective-C it doesn't want it for some reason and the other error code is Argument of '#selector' refers to instance method 'refreshWebView' that is not exposed to Objective-C mainly this is the error I need to fix thanks in advance this code is what's giving me the error refreshControl.addTarget(self, action: #selector(refreshWebView(_:)), for: UIControl.Event.valueChanged) this is for a pull to refresh the page
3
0
401
Jul ’24
new developer, need help displaying on screen
brand new newbie developer to xcode. so im doing an api call and getting back data from a mysql database. in the xcode preview window im getting data, but i cant figure out how to tie it to the screen when going into the simulator. i have screen 1 that i want to click a button to go to screen 2 that displays the data. screen one (home screen) comes up okay. cant quite figure out what im doing wrong here. im thinking its either a class issue or something to do with view or something. not sure. ive tried looking at so many different videos and i cant seem to find my answer. Any help would be appreciated. thank you View Controller: import UIKit //import SwiftUI let URL_TOURNAMENT_FETCH = "https://www.thesoftball.com/t2g_mobile_app/mobile_api.php" class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() } @IBAction func onEmailButtonPressed(_ sender: Any) { UIApplication.shared.open(URL(string: "mailto:[email]")! as URL, options: [:],completionHandler: nil) } /* @IBAction func FetchTournButton(_ sender: Any) { UIApplication.shared.open(URL(string: "https://www.thesoftball.com/t2g_mobile_app/mobile_api.php")! as URL, options: [:],completionHandler: nil) } */ @IBAction func ViewTournamentButton(_ sender: Any) { // the following is a popup let alertController = UIAlertController(title: "Welcome to My First App", message: "Hello World", preferredStyle: UIAlertController.Style.alert) alertController.addAction(UIAlertAction(title: "OK", style: UIAlertAction.Style.default, handler: nil)) present(alertController, animated: true, completion: nil) } @IBAction func account_button_pressed(_ sender: Any) { UIApplication.shared.open(URL(string: "https://www.thesoftball.com")! as URL, options: [:],completionHandler: nil) } /* struct viewDidLoadModifier: viewDidLoadModifier { @State private var didLoad = false private let action: (() -> void)? init(perform action) { } } */ } ContentView (preview works in this) import SwiftUI struct ContentView: View { @StateObject var viewModel = ViewModel() var body: some View { NavigationView{ List{ ForEach(viewModel.courses,id: \.self) { tournament in HStack { Image("") .frame(width: 5, height: 120) .background(Color.orange) VStack { Text(tournament.name).bold() Text(tournament.dates) Text(tournament.datee) Text(tournament.location) // Text(course.location) // Text(course.message) // .bold() } } .padding(0) } } .navigationTitle("Tournaments") // .onAppear { viewModel.fetch()} .onAppear(perform: viewModel.fetch) } } } struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView() } }
0
0
360
Jul ’24
Issue with 24-hour time format in UIDatePicker and possible workarounds
Dear Apple Support Team, I am currently developing a control in my app that uses UIDatePicker for time input. To ensure that the time display format is consistently in 24-hour notation regardless of the region, I have set the locale of UIDatePicker to ‘systemLocale’. However, while this worked as expected up to iPadOS15, displaying the time in 24-hour format, it has switched to a 12-hour format from iPadOS16 onwards. I am wondering if there have been any changes in the behavior of UIDatePicker’s locale between the updates from iPadOS15 to iPadOS16? Additionally, I would like to know if there are any workarounds to this issue that do not involve modifying the program. In other words, is there a way to revert back to the 24-hour format without changing the code? Any information you could provide on this issue would be greatly appreciated. Thank you for your assistance.
2
0
644
Aug ’24
Use of SceneDelegate not working
I am trying to configure scenes to capture a redirect URL after a successful login attempt. I am using OAuth code flow. This is the code I have so far: ios_app.swift import SwiftUI @main struct ios_appApp: App { @UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate let persistenceController = PersistenceController.shared @StateObject private var authState = AuthState() var body: some Scene { WindowGroup { ContentView() .environment(\.managedObjectContext, persistenceController.container.viewContext) .environmentObject(authState) } } } AppDelegate.swift import UIKit import AWSMobileClient import GoogleSignIn class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { print("AppDelegate: didFinishLaunchingWithOptions") AWSMobileClient.default().initialize { (userState, error) in if let userState = userState { print("UserState: \(userState)") } else if let error = error { print("Error initializing AWSMobileClient: \(error.localizedDescription)") } } GIDSignIn.sharedInstance.restorePreviousSignIn { user, error in if let error = error { print("Error restoring previous Google Sign-In: \(error.localizedDescription)") } } return true } } SceneDelegate.swift import UIKit import SwiftUI import GoogleSignIn class SceneDelegate: UIResponder, UIWindowSceneDelegate { var window: UIWindow? func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { print("SceneDelegate: scene willConnectTo") guard let windowScene = (scene as? UIWindowScene) else { print("SceneDelegate: Invalid windowScene") return } let window = UIWindow(windowScene: windowScene) let contentView = ContentView().environmentObject(AuthState()) window.rootViewController = UIHostingController(rootView: contentView) self.window = window window.makeKeyAndVisible() print("SceneDelegate: window initialized and visible") } func sceneDidDisconnect(_ scene: UIScene) { print("SceneDelegate: sceneDidDisconnect") } func sceneDidBecomeActive(_ scene: UIScene) { print("SceneDelegate: sceneDidBecomeActive") } func sceneWillResignActive(_ scene: UIScene) { print("SceneDelegate: sceneWillResignActive") } func sceneWillEnterForeground(_ scene: UIScene) { print("SceneDelegate: sceneWillEnterForeground") } func sceneDidEnterBackground(_ scene: UIScene) { print("SceneDelegate: sceneDidEnterBackground") } func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) { guard let url = URLContexts.first?.url else { print("SceneDelegate: No URL found in URLContexts") return } print("SceneDelegate: openURLContexts with URL: \(url)") if GIDSignIn.sharedInstance.handle(url) { print("SceneDelegate: Google Sign-In handled URL") return } if url.scheme == "myurlscheme" || (url.scheme == "https" && url.host == "mydomain.com" && url.path == "/mobile-auth-callback") { print("SceneDelegate: Handling auth response for URL: \(url)") AuthService.shared.handleOAuthCallback(url: url) } else { print("SceneDelegate: URL scheme not handled: \(url.scheme ?? "No scheme")") } } func scene(_ scene: UIScene, continue userActivity: NSUserActivity) { print("SceneDelegate: continue userActivity") if userActivity.activityType == NSUserActivityTypeBrowsingWeb { if let url = userActivity.webpageURL { handleUniversalLink(url: url) } } } private func handleUniversalLink(url: URL) { print("SceneDelegate: Handling universal link: \(url)") if url.path.contains("/mobile-auth-callback") { let queryItems = URLComponents(url: url, resolvingAgainstBaseURL: false)?.queryItems let code = queryItems?.first(where: { $0.name == "code" })?.value if let code = code { print("SceneDelegate: Received code: \(code)") AuthService.shared.exchangeCodeForToken(code: code) } else { print("SceneDelegate: No code found, handling email/password callback") AuthService.shared.handleEmailPasswordCallback(url: url) } } } } Also introduced this configuration in Info.plist: <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>UIApplicationSceneManifest</key> <dict> <key>UIApplicationSupportsMultipleScenes</key> <true/> <key>UISceneConfigurations</key> <dict> <key>UIWindowSceneSessionRoleApplication</key> <array> <dict> <key>UISceneConfigurationName</key> <string>Default Configuration</string> <key>UISceneDelegateClassName</key> <string>ios-app.SceneDelegate</string> </dict> </array> </dict> </dict> ...Other parameters </dict> </plist> I am using the simulator to launch my app and can see AppDelegate related logs but I am not seeing any SceneDelegate logs (I suppose because it is not being initialized nor called). I have tried restarting the computer/Xcode, clean and rebuild the application but none of the things I tested work. Is there any part of my code wrong? Any other idea here?
0
0
424
Jul ’24