Post not yet marked as solved
Okay so I'm getting this log every time I present a UIAlertController:
Mac Catalyst: Presenting view controller <UIAlertController: 0x10f027000> from detached view controller <MyViewController: 0x10d104080> is not supported, and may result in incorrect safe area insets and a corrupt root presentation. Make sure <MyViewController: 0x10d104080> is in the view controller hierarchy before presenting from it. Will become a hard exception in a future release.
A few points:
MyViewController is not detached and the presentation shows just fine.
I specifically check for this before presenting the alert controller like so:
BOOL okayToPresentError = (self.isViewLoaded
&& self.view.window != nil);
if (okayToPresentError)
{
[self presentErrorInAlertController:error];
}
else
{
//Wait until view did appear.
self.errorToPresentInViewDidAppear = error;
}
It spews out every time an error is fed back to my app and I present the alert controller (I can turn off the network connection and I show an alert controller with a "retry" button in it which will loop the error back so I can replay the error alert presentation over and over again) .
Every time the alert controller is presented, I get this spewing in the console. Please don't start throwing hard exceptions because the check is faulty.
Post not yet marked as solved
Hey everybody!
Does anyone know if there's a UIKit API that's equivalent to SwiftUI's View/offset(z:)?
https://developer.apple.com/documentation/swiftui/view/offset(z:)
I'd like to translate a UIView forward in space a little bit on visionOS.
❤️
Post not yet marked as solved
**Run this code on IOS 16 or below, or build with XCode 14, and when you rotate your phone landscape you get a Tab Bar with with labels below the images rather than the default of labels to the left **
extension UITabBar {
// the Master view controller shows the UITabBarItem icon next to the text
override open var traitCollection: UITraitCollection {
if UIDevice.current.userInterfaceIdiom == .pad {
return UITraitCollection(horizontalSizeClass: .compact)
}
// return super.traitCollection
if UIDevice.current.userInterfaceIdiom == .phone {
return UITraitCollection(horizontalSizeClass: .compact)
}
return super.traitCollection
}
}
_**_**Build with Xcode 15 and run on IOS 17 Iphone and you get the following error message **_**_
Thread 1: "A trait environment returned a trait collection with unspecified values for traits that are not allowed to be unspecified. This is a serious application bug and will cause undefined behavior. This issue may be caused by your class overriding the traitCollection property getter, which is not supported. Make sure to use the appropriate API if you are trying to override traits. Trait Environment: <UITabBarSwappableImageView: 0x103847660; frame = (0 0; 0 0); opaque = NO; userInteractionEnabled = NO; image = <UIImage:0x281372c70 CGImage anonymous; (34 38)@3>; layer = <CALayer: 0x282135ea0>>; Trait Collection: <UITraitCollection: 0x10386d230; HorizontalSizeClass = Compact, PreferredContentSizeCategory = L>"
_____Serious bug? more than 100,000 users over 4 years and never had an issue with this code until now. This is preventing us from building with Xcode 15 and affecting our production.
It was suggested we try this, it prevents the crash but does not work.**
____**_
`
` if UIDevice.current.userInterfaceIdiom == .phone {
if #available(iOS 17.0, *) {
return UITraitCollection(traitsFrom: [super.traitCollection, UITraitCollection(horizontalSizeClass: .compact)])
} else {
return UITraitCollection(horizontalSizeClass: .compact)
}
}
`
Post not yet marked as solved
I want to switch from a running CarPlay appto another CarPlay app without going through CarPlay HOME.I have tried openURL using URL scheme.As a result, the app started on the smartphone,but the app on the Simulator did not switch.I would like to know the URLif there is official information on CarPlay application switching.
Post not yet marked as solved
I am having issues with the Font Sizes on iOS17 Beta. When running the app in the simulator and on the device, the font weight for my app suddenly changed. For example, it has always been "Regular" and it changed to "Semibold" even thought its set to be in "Regular".
I am also adding a new label, and no matter what I do to the size, it does not change. On the storyboard is shows the correct size I set, but then running it on the simulator or in my device running iOS17 Beta it shows smaller or the the regular size of 17.
Is anyone else experiencing this issue?
A handful of my customers have reported a consistent freeze in my app (smells like either a thread deadlock or an infinite recursion to me). It's working properly for most people, but if 3 people are reporting it to me that says to me that probably 300 are experiencing it but staying quiet.
It happens every time they take a certain kind of action. But it never happens to me so I can't figure out what is breaking.
No crash is happening, so I'm not getting any reports via Firebase.
It doesn't appear to be related to their data, because they can have someone else use a different device, login to their account, download all of their data, and then successfully do the thing that freezes 100% of the time on their original device.
I've got one of these customers set up on TestFlight so I can send them test versions of the app with some debug collection code. I created my own version of a tracelog and write a line to a file whenever I start/end a function. I've added those tracelog calls to a bunch of methods and classes (but not all).
The action that causes the freeze is when they tap Edit on a record. What's supposed to happen is that I modally present a nav controller containing an EditBlahViewController.
The trace logs show that the EditBlahViewController gets through viewDidLoad, viewWillAppear, two rounds of viewWillLayoutSubviews/viewDidLayoutSubviews... but then never gets to viewDidAppear.
I've tried updating more and more functions/classes with the tracelog calls, but I can't find any infinite recursions. I've added tracelogs to all calls involving dispatching to other threads (especially synchronous dispatches to the main thread) but I don't see any deadlocks. Every dispatch to main starts and ends properly and then goes on to the next thing.
User is on iOS 16.6.1 with an iPhone 12.
I don't know what else to try. How can I debug this at a distance and figure out where the problem is?
Post not yet marked as solved
New in iOS 17 is NSCollectionLayoutDimension uniformAcrossSiblingsWithEstimate: method.
I have two collection view items positioned side by side in a a grid and would like to use this feature to give them equal heights.
I configure the items like so:
-Each "box" in grid is made up of two vertical items
-Title item configured with a fractional width of 0.5 and a estimated height.
-Description item configured with a fractional width of 0.5 and a estimated height.
Then the "box" wraps both the "title item" and a description item vertically
NSCollectionLayoutSize *boxSize = [NSCollectionLayoutSize sizeWithFractionalWidth:0.5 estHeightUniformAcrossSiblings:estTitleHeight+estDescriptionheight]];
NSCollectionLayoutGroup *boxGroup = [NSCollectionLayoutGroup verticalGroupWithLayoutSize:boxSize
subitems:@[titleItem,descriptionItem]];
//Repeat the box twice to make a side by side grid.
//entireRowSize is fractional width of 1.0 and estimated height (not uniform across siblings).
NSCollectionLayoutGroup *sideBySideGroup = [NSCollectionLayoutGroup horizontalGroupWithLayoutSize:entireRowSize
repeatingSubitem:boxGroup
count:2];
But at runtime the grids do not have equal heights. It looks exactly the same as it was on iOS 16. Am I doing something wrong? Thanks in advance.
Post not yet marked as solved
Vertical writing in CJK is used in some Apple apps in iOS 17 and macOS Sonoma (e.g. Contacts and Calendar).
Where are there APIs to use vertical writing in SwiftUI or UIKit?
Post not yet marked as solved
In macOS 14, NSAttributedString.Key.verticalGlyphForm has been deprecated. This key was previously used for rendering text vertically, particularly in languages like Chinese, Japanese, and Korean. I'm curious about the reasons behind its deprecation and would appreciate insights into alternative methods for displaying vertical text.
Post not yet marked as solved
Incident Identifier: C7E20EA3-7315-404A-83D5-8DBD20F8406B
Hardware Model: iPad13,1
Process: 月儿记账 [352]
Path: /private/var/containers/Bundle/Application/1F4F62A3-A990-4094-9982-DB0CFBB82662/月儿记账.app/月儿记账
Identifier: top.bytearts.money
Version: 1.6.0 (000194)
AppStoreTools: 15A240a
AppVariant: 1:iPad13,1:15
Code Type: ARM-64 (Native)
Role: Foreground
Parent Process: launchd [1]
Coalition: top.bytearts.money [491]
Date/Time: 2023-09-28 00:34:09.5371 +0800
Launch Time: 2023-09-28 00:34:03.1161 +0800
OS Version: iPhone OS 17.0 (21A329)
Release Type: User
Report Version: 104
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Termination Reason: SIGNAL 6 Abort trap: 6
Terminating Process: 月儿记账 [352]
Triggered by Thread: 0
Last Exception Backtrace:
0 CoreFoundation 0x19862a5e0 __exceptionPreprocess + 164 (NSException.m:249)
1 libobjc.A.dylib 0x1909abc00 objc_exception_throw + 60 (objc-exception.mm:356)
2 Foundation 0x197b944d4 -[NSAssertionHandler handleFailureInFunction:file:lineNumber:description:] + 172 (NSException.m:261)
3 UIKitCore 0x19a844904 _UIGraphicsBeginImageContextWithOptions + 568 (UIGraphics.m:407)
4 UIKitCore 0x19a8428d0 -[UIImageView(Pretiling) _updatePretiledImageCacheForImage:] + 812 (UIImageView_Pretiling.m:171)
5 UIKitCore 0x19a7920b0 -[UIImageView _updateImageViewForOldImage:newImage:] + 496 (UIImageView.m:3604)
6 UIKitCore 0x19a75c0fc -[UIImageView _resolveImagesWithPreviouslyDisplayedImage:] + 836 (UIImageView.m:3409)
7 UIKitCore 0x19a75bd74 -[UIImageView _setImage:invalidatingPendingSymbolTransitions:] + 280 (UIImageView.m:1379)
8 UIKitCore 0x19a7c1ab0 -[UIButtonLegacyVisualProvider _updateBackgroundImageView] + 124 (UIButtonLegacyVisualProvider.m:1795)
9 UIKitCore 0x19a7c02c4 -[UIButtonLegacyVisualProvider layoutSubviews] + 100 (UIButtonLegacyVisualProvider.m:2379)
10 UIKitCore 0x19a7c021c -[UIButton layoutSubviews] + 40 (UIButton.m:2811)
11 UIKitCore 0x19a7831d8 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1528 (UIView.m:19754)
12 QuartzCore 0x199b9b888 CA::Layer::layout_if_needed(CA::Transaction*) + 500 (CALayer.mm:10783)
13 QuartzCore 0x199b9b410 CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 144 (CALayer.mm:2594)
14 QuartzCore 0x199ba194c CA::Context::commit_transaction(CA::Transaction*, double, double*) + 464 (CAContextInternal.mm:2792)
15 QuartzCore 0x199b9ac3c CA::Transaction::commit() + 648 (CATransactionInternal.mm:432)
16 QuartzCore 0x199b9a8e4 CA::Transaction::flush_as_runloop_observer(bool) + 88 (CATransactionInternal.mm:942)
17 CoreFoundation 0x1985731dc __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 36 (CFRunLoop.c:1789)
18 CoreFoundation 0x198571be4 __CFRunLoopDoObservers + 548 (CFRunLoop.c:1902)
19 CoreFoundation 0x198571300 __CFRunLoopRun + 1028 (CFRunLoop.c:2983)
20 CoreFoundation 0x198570e18 CFRunLoopRunSpecific + 608 (CFRunLoop.c:3420)
21 GraphicsServices 0x1db02d5ec GSEventRunModal + 164 (GSEvent.c:2196)
22 UIKitCore 0x19a97f350 -[UIApplication _run] + 888 (UIApplication.m:3690)
23 UIKitCore 0x19a97e98c UIApplicationMain + 340 (UIApplication.m:5275)
24 月儿记账 0x10067cfcc main + 68 (main.m:18)
25 dyld 0x1bad53d44 start + 2104 (dyldMain.cpp:1269)
Post not yet marked as solved
Body:
Hello,
I am facing a challenging issue with my SwiftUI iOS application, which is designed to work on an iPad and connect to an external display. The app, called "EasyJoin," is intended to provide a single-touch interface for joining conference meetings. It pulls events from a calendar and provides a "Join" button to connect to the meeting.
The Goal:
Mirror the app on an external display in its native aspect ratio.
Also mirror any other client applications launched from EasyJoin (such as Google Meet, Teams, WebEx, Zoom) to the external display in its native aspect ratio.
The Issue:
While I have been successful in displaying the app on the external display, the iPad screen goes black as soon as the external display is connected. I need both the iPad and the external display to show the app simultaneously, each in their native aspect ratios.
What I've Tried:
Created separate UIWindow objects for the internal and external displays.
Used NotificationCenter to listen for UIScreen.didConnectNotification and UIScreen.didDisconnectNotification.
Tried managing windows through both AppDelegate and SceneDelegate.
Explicitly set windowLevel for both internal and external windows.
Despite these efforts, the issue persists. The external display works as expected, but the iPad screen remains black.
Here is a snippet of my SceneDelegate.swift:
// ... (Code for setting up UIWindow and listening for screen connect/disconnect)
@objc func screenDidConnect(notification: Notification) {
// ... (Code for setting up external UIWindow)
externalWindow?.isHidden = false
}
@objc func screenDidDisconnect(notification: Notification) {
externalWindow?.isHidden = true
externalWindow = nil
}
I would appreciate any guidance or suggestions to resolve this issue. Thank you!
Feel free to copy and paste this into a new post on the Apple Developer Forums. Hopefully, you'll get some specialized assistance that can help resolve the issue.
Post not yet marked as solved
In Xcode 15 Live Previews are available for UIKit view controllers and views. However I noticed they do not work if the deployment target is < 17.0.
If I try to make a live preview for a view controller like so:
#Preview {
let someVC = ViewController()
return someVC
}
It doesn't load.
The error is described below:
== PREVIEW UPDATE ERROR:
CompileDylibError: Failed to build ASwiftViewController.swift
Compiling failed: module 'SwiftUI' has no member named 'VStack'
If I raise the deployment target to iOS 17 it starts working.
Post not yet marked as solved
I have a UIViewController subclass I'm using in Mac Catalyst. This view controller is only ever presented as a sheet. When I try to make a live preview for it the preview is displayed a gigantic size (not the sheet's actual size at runtime). I made a separate thread about this: https://developer.apple.com/forums/thread/738641
In order to be able to preview the view controller for Mac Catalyst at the desired size I figured I'd present it on another view controller.
#Preview {
let wrapperVC = WrapperViewController()
return wrapperVC
}
//In WrapperViewController
override func viewDidAppear(_ animated: Bool)
{
super.viewDidAppear(animated)
if (firstViewDidAppear)
{
firstViewDidAppear = false
view.backgroundColor = UIColor.yellow
let realVC = ActualVCIWantToPreview()
realVC.modalPresentationStyle = .formSheet
present(realVC, animated: false);
}
}
But that's not working. However if I change the device from Mac to iPad it does work so it appears modal presentations aren't working for Live Previews on Mac Catalyst (unless I'm doing something wrong but Xcode is reporting no errors it just isn't showing my presented view controller).
Post not yet marked as solved
I have a Mac Catalyst app. When using "Live Previews" in Xcode 15 for a view controller of mine the live preview renders at a gigantic size in the Preview.
This view controller is only ever presented as a "sheet" on Mac at a fixed size so ideally I'd like to be able to specify the "window size" for the preview environment.
Is there a way to do this? Thanks in advance.
Post not yet marked as solved
Now that live previews are available in UIKit (source: https://developer.apple.com/wwdc23/10252)
I was wondering how to get a UIViewController from Objective-C. The Swift macro looks like this:
#Preview {
var controller = SomeViewController()
return controller;
}
Is there a way to get a live preview for UIViewControllers/UIViews written in Objective-C (other than wrapping it as a child view controller in an empty swift view controller)?
Post not yet marked as solved
I recently upgraded Xcode15 and launched the app with iOS 17 simulator, i found that my custom UICollectionView is not redering. After analyzing I found that to fix this I have to make MinimumLineSpacingForSectionAt non-zero. But I want to keep minimumLineSpacingForSectionAt as zero in my app with which my UICollectionView was working fine in iOS16 and previous iOS versions. please suggest to reson behind this behaviour and share the solution.
Post not yet marked as solved
In my application i want to override the default behavior of undo and redo .In ipad , when user presses cmd+c/v , want to trigger some other action instead of default copy/paste . And in case of ipad , i want to trigger diffrent action for three finger touch gesture . Is it possible to do that?
Post not yet marked as solved
In an APP packaged with xcode13 and running on a mobile phone with iOS17 system, the UICollectionView appears blank.
UICollectionView uses a custom UICollectionViewLayout, which overrides the collectionViewContentSize method. The width returned in this method is 0, which will cause cellForItemAtIndexPath not to be called. Setting it to 1 can also display normally.
Post not yet marked as solved
On iOS17, UIDevice.current.batteryLevel is returning values rounded to 0.05, such as 1, 0.95, 0.9. Which used to be a 1% granularity in iOS16. Is this a bug or a new feature?
Post not yet marked as solved
Hello,
It appears that there is a memory leak when utilizing a UISheetPresentationController. Please take a look at this simple project available here.
On the iOS 16.4 simulator for iPhone 14, if I dismiss the sheet, SheetViewController is successfully deinitialized. However, when I run this code on a real device (iPhone XR, iOS 16.4.1), the deinit of SheetViewController is not triggered. It seems like the presentation controller which holds a reference to SheetViewController stays in memory, captured by a closure.
Here is the memory leak caused by iOS:
Is this bug already known to the community? Should I report it? Is there any workaround for this issue?
Thank you.