In my project, I create a UITabbarController using the storyboard. Later, I change the images and title of the individual tabbar items in the code. This works with the new tabbar controller from iOS 18, with one exception: If the iPad switches to a horizontally compact mode and thereby triggers the old tabbar (at the bottom of the screen), the images and titles from the storyboard appear there, not the values changed in the code. Am I doing something wrong or is this a bug?
UIKit
RSS for tagConstruct and manage graphical, event-driven user interfaces for iOS or tvOS apps using UIKit.
Post
Replies
Boosts
Views
Activity
Whenever a UITextView has a large textContainerInset it starts scrolling upwards rapidly when selecting text. For my use case, I have a custom view that I display in the text view to show the comment you are writing a reply to. To accomplish this, I use the textContainerInset and set the top portion of that inset to a large value.
Here is a video showing the issue: https://streamable.com/9z57ok
I've also made a very simple sample project to demonstrate and here is the main view controller code: https://gist.github.com/rickharrison/9cf563bcb22130bfafc7d3b5d37c55f2
Is it possible to disable scrolling of the UITextView while the selection UI is shown? Or is there another way I should inset the text to edit?
I found another thread with this issue from years ago, but no solution - https://developer.apple.com/forums/thread/129882
Here is a screenshot of the app:
And here follows the code: it's a view controller with a collection view with plain list layout and a diffable data source.
It has 1 section with 2 rows.
The 1st row's content configuration is UIListContentConfiguration.cell(), and it has some text.
The 2nd row has an empty content configuration instead.
As you can see, if you run the app, the separator insets are different for the two rows.
Did I make a mistake?
If this is expected behavior instead, is there an easy fix?
import UIKit
class ViewController: UIViewController {
var collectionView: UICollectionView!
var dataSource: UICollectionViewDiffableDataSource<String, String>!
var snapshot: NSDiffableDataSourceSnapshot<String, String> {
var snapshot = NSDiffableDataSourceSnapshot<String, String>()
snapshot.appendSections(["main"])
snapshot.appendItems(["one", "two"])
return snapshot
}
override func viewDidLoad() {
super.viewDidLoad()
configureHierarchy()
configureDataSource()
}
func configureHierarchy() {
collectionView = .init(
frame: view.bounds,
collectionViewLayout: createLayout()
)
view.addSubview(collectionView)
collectionView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
}
func createLayout() -> UICollectionViewLayout {
return UICollectionViewCompositionalLayout { section, layoutEnvironment in
let config = UICollectionLayoutListConfiguration(appearance: .plain)
return NSCollectionLayoutSection.list(using: config, layoutEnvironment: layoutEnvironment)
}
}
func configureDataSource() {
let firstCellRegistration = UICollectionView.CellRegistration<UICollectionViewListCell, String> { cell, indexPath, itemIdentifier in
var contentConfiguration = UIListContentConfiguration.cell()
contentConfiguration.text = "Hello"
cell.contentConfiguration = contentConfiguration
}
let secondCellRegistration = UICollectionView.CellRegistration<UICollectionViewListCell, String> { cell, indexPath, itemIdentifier in
}
let emptyCellRegistration = UICollectionView.CellRegistration<UICollectionViewListCell, String> { cell, indexPath, itemIdentifier in
}
dataSource = .init(collectionView: collectionView) { collectionView, indexPath, itemIdentifier in
switch itemIdentifier {
case "one":
collectionView.dequeueConfiguredReusableCell(using: firstCellRegistration, for: indexPath, item: itemIdentifier)
case "two":
collectionView.dequeueConfiguredReusableCell(using: secondCellRegistration, for: indexPath, item: itemIdentifier)
default:
collectionView.dequeueConfiguredReusableCell(using: emptyCellRegistration, for: indexPath, item: itemIdentifier)
}
}
dataSource.apply(self.snapshot, animatingDifferences: false)
}
}
Xcode 15.4, iPhone 15 Pro simulator, iOS 17.5, MacBook Air M1 8GB, macOS 14.5.
Dear All,
I am currently facing a challenge with updating the contentScaleFactor of my PKCanvasView, which is embedded within a custom UIScrollView. I have configured the PKCanvasView to have both its maximum and minimum zoomScale set to 1.0, ensuring that users can only zoom into the UIScrollView and not directly into the PKCanvasView.
Upon the completion of a zoom action in my UIScrollView, a notification is published and received by the PKCanvasView. This triggers a function intended to update the contentScaleFactor. However, this process is not functioning as expected.
Despite consulting with several engineers at WWDC24 and exploring multiple potential solutions, the issue remains unresolved.
Interestingly, when zooming into a PDF in the Documents app on iOS 17, the strokes are re-rendered perfectly, while in previous iOS versions, this bug persists in the Documents app.
I would greatly appreciate any insights or solutions from those who might have encountered and resolved this issue.
Thank you in advance for your assistance.
Best regards,
Timon
Hi all,
My app uses SpriteKit views which are rendered into images for various uses. For some reason, the same code performs worse on a newer CPU than on an older one.
My A13 Bionic flies through the task at high resolution and 60FPS while CPU usage is <60%, while the A15 Bionic chokes and sputters at a lower resolution and 30FPS.
Because of how counterintuitive this is, it took me a while to isolate the call directly responsible--with UIView.drawHierarchy commented out, both devices returned to their baseline performances.
guard let sceneView = skScene.view
else { return }
let size = CGSize(width: outputResolution, height: outputResolution)
return UIGraphicsImageRenderer(size: size).image { context in
let rect = CGRect(origin: .zero, size: size)
sceneView.drawHierarchy(in: rect, afterScreenUpdates: false)
}
Does anyone know why this is the case, and how to fix it?
I tried using UIView.snapshotView, which is supposedly much faster, but it only returns blank images. Am I using it wrong or does it simply not work in this context?
sceneView.snapshotView(afterScreenUpdates: false)?.draw(rect)
Any hints or pointers would be greatly appreciated
I have few UIWindow in my application, one has alert level and another one has normal. When I present one window above another the voice over reads elements that are covered by the alert window. How I can suppress this behaviour and make the voice over read elements on a visible key window only. I don't like an option to hide accessibility for the bottom window, so I am wondering are there any other ways to do it?
Hello Apple Developers,
Here is an interesting and quite challenging problem. It is a real problem in our product Drinkit (https://apps.apple.com/app/id1495622004) that we can't solve elegantly. There are three scrolls: a horizontal UIPageViewController, inside each page there is a vertical and paginated UIScrollView, and on top of all this, there is a horizontal UIScrollView with tabs to manage the UIPageViewController.
We want to make the vertical scroll on these tabs forward to the view controller on the current page of the UIPageViewController so that the page in the vertical UIScrollView scrolls accordingly.
I have created a prototype to reproduce this situation.
https://github.com/zsergey/Scrollviews
Thank you for your help!
Keyboard shortcuts that use the Command key modifier are not handled properly, and the UIKeyCommand action and pressesBegan and pressesEnded methods are not called at all or are called unreliably.
It is easy to reproduce using this snippet:
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let textView = MyTextView()
textView.font = UIFont.systemFont(ofSize: 24)
textView.text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec efficitur eros vitae dui consectetur molestie. Integer sed massa rutrum, pharetra orci eget, molestie sem. Fusce vestibulum massa nisi, vitae viverra purus condimentum et. Sed nec turpis aliquam, tempus enim sit amet, gravida libero. Praesent scelerisque venenatis nunc, vel convallis nisl auctor vitae. Mauris malesuada tempus pharetra. Nullam ornare venenatis ullamcorper. In viverra feugiat tincidunt. Nullam iaculis urna eu semper rutrum. "
textView.isEditable = true
textView.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(textView)
NSLayoutConstraint.activate([
textView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor),
textView.bottomAnchor.constraint(equalTo: view.bottomAnchor),
textView.leadingAnchor.constraint(equalTo: view.leadingAnchor),
textView.trailingAnchor.constraint(equalTo: view.trailingAnchor)
])
}
}
class MyTextView: UITextView {
override var keyCommands: [UIKeyCommand]? {
[
UIKeyCommand(input: "[", modifierFlags: .command, action: #selector(commandAction(_:)))
]
}
override func pressesBegan(_ presses: Set<UIPress>, with event: UIPressesEvent?) {
print("pressesBegan")
super.pressesBegan(presses, with: event)
}
override func pressesEnded(_ presses: Set<UIPress>, with event: UIPressesEvent?) {
print("pressesEnded")
super.pressesEnded(presses, with: event)
}
@objc private func commandAction(_ sender: Any?) {
print("commandAction")
}
}
Run the code in a Simulator or on a Device with an external keyboard connected. Observe the console for a string "commandAction" when pressing the combination Command + [ on the keyboard. Result it not predictable, the UIKeyCommand is not called at all, or called in a loop, or sometimes called after change selection in the UITextView. The same with pressesBegan and pressesEnded. Compare results with the change where instead of Command modifier, we use Control modifier eg.: "UIKeyCommand(input: "[", modifierFlags: .command, action: #selector(commandAction(_:))" - now each keyboard shortcut is properly reported to methods.
The UIKeyCommand.wantsPriorityOverSystemBehavior property changes nothing.
Behavior reproducible in the Simulator and on the Device (iPad)
(the issue was confirmed during online WWDC24 Labs)
Reported as FB13897415
How to
Hide the UIMenuController pop-up in PDFKit.
Customize the UIMenuItem in the UIMenuController
Hi Team,
I am using CGPDFPage and CGContext to convert the PDF to an image. It is working fine in all circumstances but fails in one circumstance where the size of the PDF is above 50 MB and when the application is made to be on background and again opened. It is also occurring only on physical devices; emulators are working fine. We are using the following code for this conversation:
fileStream.CopyTo(memoryStream);
CGDataProvider provider = new CGDataProvider(memoryStream.ToArray());
CGPDFDocument cGPDFDocument = null;
image = null;
cGPDFDocument = new CGPDFDocument(provider);
using(CGPDFPage pdfPage = cGPDFDocument?.GetPage(1))
{
if (pdfPage != null)
{
CGRect rect = pdfPage.GetBoxRect(CGPDFBox.Media);
if (pdfPage.RotationAngle == 90 || pdfPage.RotationAngle == 270)
{
rect = new CGRect(rect.X, rect.Y, rect.Height, rect.Width);
}
nfloat factor = (nfloat)0.5;
CGRect bounds = new CGRect(rect.X * factor, rect.Y * factor, rect.Width * factor, rect.Height * factor);
UIGraphics.BeginImageContext(bounds.Size);
CGContext context = UIGraphics.GetCurrentContext();
context.SetFillColor(1.0f, 1.0f, 1.0f, 1.0f);
context.FillRect(bounds);
context.TranslateCTM(0, bounds.Height);
context.ScaleCTM(factor, -factor);
context.ConcatCTM(pdfPage.GetDrawingTransform(CGPDFBox.Crop, rect, 0, true));
context.SetRenderingIntent(CGColorRenderingIntent.Default);
context.InterpolationQuality = CGInterpolationQuality.Default;
context.DrawPDFPage(pdfPage);
image = UIGraphics.GetImageFromCurrentImageContext();
UIGraphics.EndImageContext();
imageView.Image = image;
parentView.AddSubview(imageView);
}
}
We have added a simple application created on Xamarin.iOS platform that replicates this issue in Assets we have added the PDF with this issue https://www.syncfusion.com/downloads/support/directtrac/general/ze/PdfToImageSample-556012354
We have recorded this for the reference, https://www.syncfusion.com/downloads/support/directtrac/general/ze/CrashBGImgRec-1376481150
This issue is constantly occurring on the "context.DrawPDFPage(pdfPage);" line in my application. On the provided sample, this issue is occurring consistently when the break point is placed on the "context.DrawPDFPage(pdfPage);" line. It also occurs randomly without placing the breakpoint.
We are invoking this function on DidEnterBackground override method of AppDelegate
Do we need to set any to properly retrieve the image from CGPDFPage and add them into context?
Our on field app is facing significant crashes at CA::Transaction::commit() from QuartzCore.
The crash report does not point to any code in our app and the information available is very limited.
It's a EXC_BAD_ACCESS KERN_INVALID_ADDRESS crash.
We have tried using sanitisers and zombies but unable to reproduce the crash locally.
Can someone help explain and point in right direction?
Below are the crash details.
Full crash report
Distributor ID: com.apple.AppStore
Hardware Model: iPhone15,3
AppStoreTools: 15F31e
AppVariant: 1:iPhone15,3:16
Code Type: ARM-64 (Native)
Role: Foreground
Parent Process: launchd [1]
Date/Time: 2024-06-03 20:41:59.3315 +0530
Launch Time: 2024-06-03 19:15:20.6051 +0530
OS Version: iPhone OS 17.4.1 (21E236)
Release Type: User
Baseband Version: 2.51.04
Report Version: 104
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_INVALID_ADDRESS at 0x0000000000000110
Exception Codes: 0x0000000000000001, 0x0000000000000110
VM Region Info: 0x110 is not in any region. Bytes before following region: 4372119280
REGION TYPE START - END [ VSIZE] PRT/MAX SHRMOD REGION DETAIL
UNUSED SPACE AT START
--->
__TEXT 104994000-105420000 [ 10.5M] r-x/r-x SM=COW /var/containers/Bundle/Application/
Termination Reason: SIGNAL 11 Segmentation fault: 11
Terminating Process: exc handler [35195]
Triggered by Thread: 0
Kernel Triage:
VM - (arg = 0x3) mach_vm_allocate_kernel failed within call to vm_map_enter
VM - (arg = 0x3) mach_vm_allocate_kernel failed within call to vm_map_enter
VM - (arg = 0x3) mach_vm_allocate_kernel failed within call to vm_map_enter
VM - (arg = 0x3) mach_vm_allocate_kernel failed within call to vm_map_enter
Thread 0 name:
Thread 0 Crashed:
0 QuartzCore 0x000000018f4633b4 CA::Transaction::commit() + 1152 (CATransactionInternal.mm:480)
1 QuartzCore 0x000000018f4633ec CA::Transaction::commit() + 1208 (CATransactionInternal.mm:480)
2 QuartzCore 0x000000018f462e64 CA::Transaction::flush_as_runloop_observer(bool) + 88 (CATransactionInternal.mm:942)
3 UIKitCore 0x00000001900b1260 _UIApplicationFlushCATransaction + 52 (UIApplication.m:3160)
4 UIKitCore 0x00000001900b0d78 _UIUpdateSequenceRun + 84 (_UIUpdateSequence.mm:119)
5 UIKitCore 0x00000001900b0468 schedulerStepScheduledMainSection + 144 (_UIUpdateScheduler.m:1037)
6 UIKitCore 0x00000001900b0524 runloopSourceCallback + 92 (_UIUpdateScheduler.m:1186)
7 CoreFoundation 0x000000018ddc162c __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 28 (CFRunLoop.c:1957)
8 CoreFoundation 0x000000018ddc08a8 __CFRunLoopDoSource0 + 176 (CFRunLoop.c:2001)
9 CoreFoundation 0x000000018ddbf0b8 __CFRunLoopDoSources0 + 340 (CFRunLoop.c:2046)
10 CoreFoundation 0x000000018ddbdd88 __CFRunLoopRun + 828 (CFRunLoop.c:2955)
11 CoreFoundation 0x000000018ddbd968 CFRunLoopRunSpecific + 608 (CFRunLoop.c:3420)
12 GraphicsServices 0x00000001d20b34e0 GSEventRunModal + 164 (GSEvent.c:2196)
13 UIKitCore 0x0000000190230edc -[UIApplication _run] + 888 (UIApplication.m:3692)
14 UIKitCore 0x0000000190230518 UIApplicationMain + 340 (UIApplication.m:5282)
15 AppName 0x000000010542072c main + 64 (AppDelegate.swift:13)
16 dyld 0x00000001b12ded84 start + 2240 (dyldMain.cpp:1298)
We found a new crash about UIFont on iOS 18 beta, and this crash never occurred on pervious operating system. Can anyone know how to fix it and whether apple will fix it on later new beta version?
From Xcode 16.0 Beta I am getting the following error at didReceiveRemoteNotification of UIApplicationDelegate protocol:
Non-sendable type '[AnyHashable : Any]' in parameter of the protocol requirement satisfied by main actor-isolated instance method 'application(_:didReceiveRemoteNotification:)' cannot cross actor boundary; this is an error in the Swift 6 language mode
Generic struct 'Dictionary' does not conform to the 'Sendable' protocol (Swift.Dictionary)
How can I fix this warning before moving to Swift 6 mode.
we found new crash about UIFont since iOS 18 beta published.This crash never occurred on previous operating system. Can anyone give the answer that how to fix it and tell whether later beta version might fix it.
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)
I‘m using a UITextView to allow users to post messages in AR in my app virtual tags - you may check by yourself, it is free - but it just allows to append text at end with no possibility of moving the cursor or do everything else. I opened a new project adding a UITextView and everything worked fine.
What could it be, and how to know more?
thanks, Fabrizio
代码如下
(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吗
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!
}
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.
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?