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

UIKit Documentation

Post

Replies

Boosts

Views

Activity

How to interact during the Transition process?(wwdc24 UIKit consultation)
Recently I tried to apply a custom transition to a custom contextMenu. However, I want to make sure that during the transition process (which is not over yet), my contextMenu elements such as buttons can be tapped. But I tried a lot of things without success. I know you have a lot of experience, so I would like to ask you about how to implement the transition and be able to interact before it is over. I know that a UIView can be tapped during animation, but I haven't tried the button in a UIView. I've been trying to transition ViewControllers. For example, in a transition from fromViewController to toViewController, I wanted to be able to tap on a tableView in toViewController during the transition, but I was frustrated and found it very difficult to implement. I would like to ask you about the possibilities of interaction during the Viewcontrollers transition. (PS: In Github Issues, I uploaded a GIF example of the plus button on the left of the input box in iMessage. After tapping the plus button, you can tap the "Apple Cash" button before the transition is finished.) Your advice would be incredibly valuable to me. Thank you in advance for your time and assistance. [GithubLink]https://github.com/Juhnkerg/DemoForInteractionDuringTransition)
0
1
244
Jun ’24
The tint color on tableviewcell's default content config's image properties doesn't work.
Here is my code that sets the tint color of the image view in the tableview cell. func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCell(withIdentifier: "typeCell") var content = cell?.defaultContentConfiguration() // Configure content. content?.image = UIImage(imageLiteralResourceName:typesArray![indexPath.row]) content?.imageProperties.maximumSize = CGSize(width: 28.0, height: 28.0) content?.text = typesArray![indexPath.row] content?.imageProperties.tintColor = UIColor(named:typesColorsArray![indexPath.row]) cell?.contentConfiguration = content return cell! }
1
0
132
Jun ’24
UIDevice: Main actor-isolated class property 'current' can not be referenced from a non-isolated context
I have a Safari Web Extension for visionOS that reads from UIDevice.current.systemVersion in order to provide the OS version number back to the JavaScript context utilizing beginRequest(with:). When switching my project to use Swift 6, I received this obscure error: Main actor-isolated class property 'current' can not be referenced from a non-isolated context Class property declared here (UIKit.UIDevice) Add '@MainActor' to make instance method 'beginRequest(with:)' part of global actor 'MainActor' Adding @MainActor causes another issue (Main actor-isolated instance method 'beginRequest(with:)' cannot be used to satisfy nonisolated protocol requirement) which suggests adding @preconcurrency to NSExtensionRequestHandling which then breaks at Non-sendable type 'NSExtensionContext' in parameter of the protocol requirement satisfied by main actor-isolated instance method 'beginRequest(with:)' cannot cross actor boundary. What's the proper solution here? Here's a simplified snippet of my code: class SafariWebExtensionHandler: NSObject, NSExtensionRequestHandling { func beginRequest(with context: NSExtensionContext) { // ... var systemVersionNumber = "" systemVersionNumber = UIDevice.current.systemVersion // ... } }
1
0
332
Jun ’24
iOS18Bate导航栏
代码如下 (void)viewDidLoad { [super viewDidLoad]; self.navigationController.navigationBar.translucent = NO; } (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; [self.navigationController setNavigationBarHidden:true]; } 此时加载VC时顶部会出现空白,整个VC的frame的Y值向下偏移了状态栏的高度,再次切换到此VC则会恢复,这是iOS18Bate的bug吗
1
0
194
Jun ’24
The application crashes in the App Store when launch on iPhone with iOS 15.3.1.
My application is currently crashing in production in iPhone devices running iOS 15.x. The app will work as normal while running developer mode, enterprise builds and Test Flight builds. Unfortunately, I am unable to reproduce this issue even app is downloaded from the app store. I observed crash is happening at main.m. Can someone help me to reproduce this issue? How to read this crash log file? Please find the crash log details attached. 2022-03-04_14-15-23.6227_+0900-a1899fd803a4ed683466702be71b9d224b4cd5bc.crash
3
1
2.5k
Mar ’22
self.edgesForExtendedLayout=UIRectEdgeNone ios18beta move UIView down
Using the UINavigationController, jump from page A(UIViewController A) to page B (UIViewController B), and page B(UIViewController B) clicks back. When page A(UIViewController A) is returned, the view of page A(UIViewController A) moves down as a whole, and the top turns black. Reproduce steps: step1: Set “self.edgesForExtendedLayout = UIRectEdgeNone;” in the method “viewDidLoad” UIViewController - (void)viewDidLoad { [super viewDidLoad]; // step1 self.edgesForExtendedLayout = UIRectEdgeNone; } step2:Set “ self.navigationController.navigationBarHidden = YES;” in the method “viewWillAppear” UIViewController - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; // step2 self.navigationController.navigationBarHidden = YES; } step3:Set “self.navigationController.navigationBarHidden = NO;” in the method “viewWillDisappear” UIViewController - (void)viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; // step3 self.navigationController.navigationBarHidden = NO; } step4:Set “[self.navigationControllerpopViewControllerAnimated:NO];” in the method “viewWillDisappear” UIViewController When page is returned - (void)click { UIViewController *vc = [[UIViewController alloc] init]; vc.view.backgroundColor = [UIColor redColor]; [self.navigationController pushViewController:vc animated:YES]; dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ // step4,animated NO [self.navigationController popViewControllerAnimated:NO]; }); } The test found that the UIView was normal after removing the "self.edgesForExtendedLayout=UIRectEdgeNone" setting.
0
0
146
Jun ’24
ios 17.5.1 keyboard glitch on some batches on iphone 14+models(not all)
We are using Material Textfield iOS component (as directed by our client), https://github.com/material-components/material-components-ios/blob/develop/components/TextControls/README.md , after ios 17.5.1 update, for all the material textfield on some iphone 14+ models there is a keyboard appearance issue, the keyboard starts to appear but dismisses immediately on tap of any textfeild,i.e material textfield component, apple's uitextfield works properly, we have an iphone 14+ with ios 17.5.1, for us it works without any issues, our app was uploaded using xcode 14.2, not sure how to fix this issue as we are not able to reproduce it, couple of users have reported this issue, it however works on all other iphone models!!! Any help would be greatly appreciated , i understand this is a third party SDK, but how to simulate this bug, if it is happening only on some devices and on the same device models we have, are working.
1
0
487
May ’24
Apple signup button displays text in the wrong app language
In my app, I'm setting the app language to Japanese. On iPhone and iPad, the Apple sign up button still displays correctly in Japanese: "Appleでサインイン". However, when running on vision Pro, the sign up button displays in English with the text "Sign up with Apple". Is this a vision pro error? The code setting the app language is Japanese: `CFBundleDevelopmentRegion ja_JP Photos displayed on iphone and vision pro. On Iphone: On vision Pro code signup button apple: (signInAppleButton as UIControl).cornerRadius = 2.0 let tapGesture = UITapGestureRecognizer(target: self, action: #selector(handleAuthorizationAppleIDButtonPress)) signInAppleButton.addGestureRecognizer(tapGesture) signInAppleStackView.insertArrangedSubview(signInAppleButton, at: 0) Hope you can help me why Vision Pro displays English text?
0
0
183
Jun ’24
Deinitializer won't get called
I'm presenting a view controller inside a UIAction handler from the new UIButton init configuration API. But when I do it, its deinit won't get called. I'm thinking there's some sort of retain cycle? I've tried capturing [weak self] inside the closure with no success. Using the addTarget method instead, the deinit gets called as expected. What am I doing wrong? let testVC = TestViewController() lazy var testButton: UIButton = { var configuration = UIButton.Configuration.filled() //button.addTarget(self, action: #selector(buttonTapped), for: .touchUpInside) let button = UIButton(configuration: configuration, primaryAction: UIAction(handler: { action in self.present(testVC, animated: true, completion: nil) })) return button }()
1
0
285
Mar ’24
Inner UIScrollView and outer UIPanGestureRecognizer
Hi, If there are nested UIScrollViews, they will work together nicely; when the inner scroll view reaches the end of contentSize, the outer scroll view will start scrolling. Can we do the same with inner UIScrollView and outer UIView that has UIPanGestureRecognizer? I’ve tried using UIGestureRecognizerDelegate and return true in gestureRecognizer(_:shouldRecognizeSimultaneouslyWith:) but that will scroll the inner UIScrollView and fire the outer UIPanGestureRecognizer at the same time. Thanks!
1
0
149
Jun ’24
Header alignment with UICollectionLayoutListConfiguration in grouped appearance
Hello, I am using compositional layout to create list of objects. I have followed the official documentation and tried the provided sample here: https://developer.apple.com/documentation/uikit/views_and_controls/collection_views/implementing_modern_collection_views However, I have seen something weird with the ListAppearancesViewController. When I use the sample as provided (initial appearance is set to "plain"), if I change the appearance to "grouped" by clicking on the bar item, the height of the header is displayed according to the label: But if I change the initial appearance in the code to "grouped" or "insetGrouped", the height is higher: Which one is the correct behavior? Having this space or not? But with this space, the accessory is not vertically aligned with the header, which is weird. How to solve that? Thanks for the help! Nghia
1
0
96
Jun ’24
UIPasteControl Button Appearing Disabled but Still Pasting Content
Hi everyone, I've implemented a UIPasteControl in my iOS app using the following code: func displayPasteControl() { if #available(iOS 16.0, *) { let pasteControlConfig = UIPasteControl.Configuration() let newPasteControlButton = UIPasteControl(configuration: pasteControlConfig) self.inputContainerView.addSubview(newPasteControlButton) newPasteControlButton.isEnabled = true // Set constraints for this button newPasteControlButton.translatesAutoresizingMaskIntoConstraints = false newPasteControlButton.topAnchor.constraint(equalTo: self.originalPasteView.topAnchor, constant: 0).isActive = true newPasteControlButton.centerXAnchor.constraint(equalTo: self.inputContainerView.centerXAnchor).isActive = true newPasteControlButton.widthAnchor.constraint(equalTo: self.originalPasteView.widthAnchor, multiplier: 0.5).isActive = true newPasteControlButton.bottomAnchor.constraint(equalTo: self.originalPasteView.bottomAnchor, constant: 0).isActive = true newPasteControlButton.target = self.inputTextView } } I call this function in viewWillAppear: override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) displayPasteControl() } Sometimes, I've noticed that the UIPasteControl button appears in a disabled state visually, but when I press it, the content from the clipboard is still pasted. I checked the state of UIPasteControl and it indicates that it is in an enabled state. For context, the UIPasteControl target is set to a UITextView (self.inputTextView). Has anyone experienced this issue or have any idea why this might be happening? Any help would be appreciated! Thank you!
0
0
114
Jun ’24
[iPadOS 18] Make Tabbar back to previous version
It is weird putting the tabbar on top. Apple should give us a way to put the Tabbar back to bottom, just like the old version. Otherwise, I will write a custom view to bring the old feature back. Every year, WWDC brings additional workload to developers. I HATE WWDC
2
0
217
Jun ’24
uialertviewcontroller presented reset's my tableview cells, font size / attributed text (iOS18)
when presenting an uialertviewcontroller either an actionsheet or alert it seems to have some weird interaction with my tableview cells. For example, i have custom font sizes a user can set so when im loading my cell i set the font size. It looks good on load but the second i preset a uialertviewcontroller it 'reset's all the cells to the default interface builder set fontsize. Some cells i use attributed text programmatically and that all gets reset as well to 'default' interface builder label settings. Its very odd. this is in iOS 18 b1. Funny enough it seems like every beta 1 (if i recall maybe in iOS 17 or iOS 16) it did the same thing there attributed text would like 'reset' its very odd. I have a hunch this is a bug and filed a feedback, but curious if there are any workarounds, or simply just wait until its fixed :D . Thanks all !
3
0
211
Jun ’24
Mimic TV App back button in UIKit
Hi In my application I'm trying to recreate the behaviour of the back button in the Apple TV app on iOS. What I'm looking for is a way to have a material background but also making it possible to animate (with an interruptible animation) the transition when the user scrolls down in a scroll view. When searching around there seems to be 2 hacks which doesn't solve my problem. Either you add a static image for the back button, which doesn't solve any of the points I mentioned before. The other hack is to stop using the back button in the UINavigationBar and start leveraging the left button instead, which I don't want because you loose the swipe back gesture. Can you just pinpoint me what API I could use to get a similar look and feel?
0
0
182
Jun ’24
Crash in iOS18
I have a UITableView which contains a UICollectionView in the first row. It used to work fine in iOS17, but now I get a crash when running with Xcode 16 / iOS18 beta: 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:] This is my UITableView delegate call: AddEditDataCell *cell = nil; if (indexPath.section == 0) { if (indexPath.row == 0) { AddEditDataContactsCell *contactNameCell = (AddEditDataContactsCell *)[self cellForContactNamesCollectionAtIndexPath:indexPath tableView:tableView]; return contactNameCell; - (AddEditDataContactsCell *)cellForContactNamesCollectionAtIndexPath:(NSIndexPath *)indexPath tableView:(UITableView *)tableView { AddEditDataContactsCell *contactsCell = (AddEditDataContactsCell *)[self.tableView dequeueReusableCellWithIdentifier:@"ContactsCell" forIndexPath:indexPath]; if (self.collectionNameCell == nil) { self.collectionNameCell = [contactsCell.collectionView dequeueReusableCellWithReuseIdentifier:@"LogContactNameCollectionCellIdentifier" forIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]]; contactsCell.nameCellDelegate = self; } contactsCell.frame = CGRectZero; [contactsCell setNeedsLayout]; [contactsCell.collectionView reloadData]; contactsCell.collectionViewHeightConstraint.constant = contactsCell.collectionView.collectionViewLayout.collectionViewContentSize.height; [contactsCell.collectionView.collectionViewLayout invalidateLayout]; return contactsCell; }
2
2
695
Jun ’24
Show a UIMenu on double-tap?
Is there a way to programmatically show a UIMenu on iOS on a double-tap event? I have an app that's been around for over a decade, so there are some UX patterns that I'm reluctant to mess around with. There is a view in my app with the following properties: Tapping the view once focuses it and brings it to the front Double-tapping it shows a view controller as a sheet, with several operations you can perform on that object Instead of the sheet, I'd like to move to context menus - they look better, and they're more familiar for users. Obviously, adding a context menu for long-press is straightforward (just use UIContextMenuInteraction). But there does not seem to be a way to show the context menu on double-tap. I've discovered that you can use UIButton with showsMenuAsPrimaryAction to show the menu on single-tap, but that doesn't quite work for me. My users expect a single tap to do something else (focus the view) and will be annoyed if single taps start showing menus instead. So, is there a way to show a context menu on double tap in iOS?
1
0
218
Jun ’24