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

visionOS console warning: Trying to convert coordinates between views that are in different UIWindows
Hello, I have an iOS app that is using SwiftUI but the gesture code is written using UIGestureRecognizer. When I run this app on visionOS using the "Designed for iPad" destination and try to use any of my gestures I see this warning in the console: Trying to convert coordinates between views that are in different UIWindows, which isn't supported. Use convertPoint:fromCoordinateSpace: instead. But I don't see any visible problems with the gestures. I see this warning printed out after the gesture takes place but before any of our gesture methods get kicked off. So now I am wondering if this is something we need to deal with or some internal work that needs to happen in UIKit. Does anyone have any thoughts on this?
0
0
114
2d
Invert VoiceOver swipe direction in a `UICollectionView`
Hello! I am working on an application with a chat feature. The chat is implemented using a UICollectionView. The content in our chat grows from the bottom and upwards, as is standard (like for instance the Messages app), with the most recent item being shown at the bottom. We have implemented this using a "hack", flipping the collection view upside-down by using a transform, and flipping the content views of the cells upside down again. This works nicely; the only remaining problem is ensuring that elements are read in the correct order for users with VoiceOver enabled. Standard behaviour with VoiceOver enabled for collection views is that swiping right moves focus to the next element, while swiping left moves focus to the previous element. Despite the collectionView being inverted (upside-down) swiping right with VoiceOver enabled moves focus to the element above, while swiping left moves focus to the element below. Is there any way to invert this behaviour? I have looked at subclassing the collection view and overriding accessibilityIncrement and accessibilityDecrement, but it did not have any effect. It seems the standard collection view accessibility container implementation does not call these methods.
1
0
163
2d
Specifying Item Spacing in UICollectionLayoutListConfiguration
Currently, I am using UICollectionViewCompositionalLayout to achieve the following list layout with spacing: We were thinking of trying out UICollectionLayoutListConfiguration due to its ability to support swipe actions. We would like to specify the spacing between each item. However, I do not find a way to specify item spacing in UICollectionLayoutListConfiguration. Does UICollectionLayoutListConfiguration not support item spacing, or have I missed something? Thanks.
1
0
79
2d
Customizing Drop Location View in UICollectionView Drag and Drop
Currently, this is how I implement the drag and move operation: collectionView.beginInteractiveMovementForItem collectionView.updateInteractiveMovementTargetPosition collectionView.endInteractiveMovement The outcome looks like the following: However, what I would like to achieve is the ability to customize the view of the "drop" location. For instance, in the following example, a red line is drawn at the target drop location: In this example, a transparent rectangle is drawn at the target drop location: May I know how these apps achieve such an effect? Thanks.
0
0
58
2d
IosViewController not reacting when adding key command
@interface CallbackClass : NSObject (void) doSomething:(UIKeyCommand*)keycmd; (UIKeyCommand*) returnKeyCommand; @end @implementation CallbackClass (void) doSomething:(UIKeyCommand*)keycmd { NSLog(@"KEY CLICKED"); } -(UIKeyCommand*) returnKeyCommand { return [UIKeyCommand keyCommandWithInput:@"a" modifierFlags:0 action:@selector(doSomething:)]; } @end void CppClass::bindKeyCommand() { CallbackClass* callbackClass = [[CallbackClass alloc] init]; [[UIApplication sharedApplication].keyWindow.rootViewController] addKeyCommand:[callbackClass returnKeyCommand]]; } This is objective-c code that is injected into QT application with C++ and Cmake. Responder chain after executing this code: Even if this key command is present is in the responder chain i dont have any reaction on click on magic keyboard. When i do this in the pure objective-c but not with with QT, C++, Cmake project. I Detect key input but only when i add my custom view controller do the subview of QIOSViewController, but then i cany click anything else on my application then. I want to be able to detect key input or somehow inject a responder into responder chain and still being able to click things on my application.
1
0
51
2d
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.
2
0
105
3d
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
139
2d
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
33
2d
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
73
4d
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?
0
0
113
5d
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
177
6d
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
145
1w
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
134
1w
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
148
4d
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
104
1w
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
137
1w