Post

Replies

Boosts

Views

Activity

iPhone 14 Pro in Landscape Mode: UIView to UIImage using UIGraphicsBeginImageContextWithOptions generates clipped image. Image is Fine on iPhone 13 Pro Max
Testing on the iPhone 14 Pro simulator I notice if the device is in the landscape orientation, snapshot images my app takes are clipped (the x origin is off). I take a snapshot of a view like this: -(UIImage*)getSnapshotForView:(UIView*)snapShotView {  UIGraphicsBeginImageContextWithOptions(snapShotView.bounds.size, NO, 0.0f); [snapShotView drawViewHierarchyInRect:snapShotView.bounds afterScreenUpdates:YES]; UIImage *snapShotImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return snapShotImage; } So I have an iPhone SE 3rd gen and all is working fine. But I figured I'd test in the iPhone 14 Pro simulator. When the simulator is in landscape mode the generated image is inset like 100 points on the x origin and the content is clipped off on the right side. So I looked at the view I was snapshotting and I thought I wasn't accounting for safe area insets properly (right and left) but I was. The subviews of the view I'm snapshotting all have the expected CGRect value for their frames. Looks like iPhone 14 Pro is rendering snapshots location on the x axis when the device is in landscape mode (at least that appears to be the case in the simulator at least). Any ideas if I'm doing something wrong?
2
0
1.4k
Sep ’22
iOS 16 -viewWillTransitionToSize:withTransitionCoordinator: bizarre value in the size parameter ((CGSize) size = (width = 414, height = 394)) on iPhone 14 Pro Max?
I noticed a bug on rotation change in my app on iPhone 14 Pro Max simulator. Basically a view in my view hierarchy is hidden when it shouldn't be. In landscape mode there isn't enough room for this view so I hide it on the iPhone (not essential). But when tilting back to portrait mode I unhide it. -(void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator {     [super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];     BOOL isIPhone = UIDevice.currentDevice.userInterfaceIdiom == UIUserInterfaceIdiomPhone;    BOOL isIPhoneAndGoingLandscapeMode = (isIPhone                                           && size.width > size.height); if (isIPhoneAndGoingLandscapeMode) { self.someView.hidden = YES; } else { self.someView.hidden = NO; } } So this view controller is presented modally (form sheet style). On iPhone 14 Pro Max on orientation -viewWillTransitionToSize:withTransitionCoordinator: is called twice and the size parameter is always: (CGSize) size = (width = 414, height = 394) This is the sized passed to my app when rotating to portrait and landscape so my isIPhoneAndGoingLandscapeMode flag always is YES because 414 > 394. The 414 x 394 size appears to be false. My view controller's view in landscape on iPhone 14 pro max logs out to: (origin = (x = 0, y = 0), size = (width = 932, height = 430)) And 932 x 430 is the size I expected to be passed to me in -viewWillTransitionToSize:withTransitionCoordinator: Unless I'm missing something can this behavior be explained?
3
0
1.9k
Sep ’22
iOS 16 UITableView: You are setting a new content configuration to a cell that has an existing content configuration, but the existing content view does not support the new configuration. Existing content configuration is nil.
I’m trying to migrate a custom UITableViewCell to use a content configuration so I can properly subclass the content view (setting a subclass on the content view in Interface Builder apparently is not supported). So when I load up the cell and set the content configuration my console is flooded with these logs: Warning: You are setting a new content configuration to a cell that has an existing content configuration, but the existing content view does not support the new configuration. This means the existing content view must be replaced with a new content view created from the new configuration, instead of updating the existing content view directly, which is expensive. Use separate reuse identifiers for different types of cells to avoid this. Make a symbolic breakpoint at UIContentConfigurationAlertForReplacedContentView to catch this in the debugger. Cell: <MyCellSubclassHere: 0x15d0b5c00> Existing content configuration: (null); New content configuration: <MyCustomConfigurationHere: 0x6000034ad190> As you can see the existing content configuration is nil. I tried setting my custom content configuration as early as possible (by overriding the designated initializer on UITableViewCell) as a workaround but that didn't work. Still console spew. And by the time cellForRowAtindexPath: is called the content configuration is always nil and has to be rebuilt (apparently UIKit is setting it to nil in prepareForReuse?) I also tried overriding -setContentConfiguration: to catch when the configuration is being set to nil but UIKit must be setting the ivar to nil directly, because the setter is never called with nil. Anyone know of a workaround? I don't want to ship an app that constantly logs this out on scroll. I opened FB11595949
Topic: UI Frameworks SubTopic: UIKit Tags:
3
0
1.6k
Sep ’22
UITableViewHeaderFooterView Not Being Cleaned Up, Abandoned Duplicate Header (not sticky) sometimes appears in the table view
I'm having a hard time tracking the cause of this/ coming up with a workaround for this potential bug in UITableView. I have a UITableView, using the default section header view (I implement -tableView:titleForHeaderInSection: and return a string).After deleting some rows using -deleteRowsAtIndexPaths:withRowAnimation: I notice sometimes an extra header view will appear inside my UITableVIew. It has the same title as the sticky header above it, but it appears the table view lost its reference to the header view but didn't clean it up from the view hierarchy (it scrolls with the table view, never sticks to the top anymore). If I manually empty the entire data source and call reload data on the table view, the abandoned header view is still visible. Has anyone run into this before and know of possible cause and/or workaround?
Topic: UI Frameworks SubTopic: UIKit Tags:
7
0
4.8k
Sep ’22
UIWindow safeAreaInset.bottom value is 20.0 on iPad even when window is presented like a "modal view controller" via UIWindowSceneActivationAction
When I open a new window via UIWindowSceneActivationAction, the window is shown like a modally presented view controller. I noticed a little layout hiccup when the window is in this state, because the window is reporting a safeAreaInset.bottom value of 20.0 even though the window is nowhere near the Home Indicator. Is there a good way to detect when a window is in this "modal like presentation" state on iPad? Size classes don't provide. I'd hate to have to sniff the frame of the window and compare it to the mainScreen frame (I know UIScreen.mainScreen is deprecated)?
Topic: UI Frameworks SubTopic: UIKit Tags:
1
0
424
Oct ’22
Xcode Extensions in Xcode 14?
I noticed an Xcode Extension I wrote a couple of years ago isn't showing up in the Editor menu of Xcode. So I opened up the project, ran the Extension and the grayed out version of Xcode shows up but my extension no longer appears in the "Editor" menu. So I just tried to create a brand new Xcode project, with an Xcode extension. Right out of the box, no code changes from the template, and I can't get the new project's Xcode extension to appear in the "Editor menu". In System Preferences the app is checked off under "Xcode Extensions" but still nowhere to be found?
1
0
3.1k
Oct ’22
if (@available(macCatalyst 15.0,*)) vs if (@available(iOS 15.0, *))
Experimenting with Mac Catalyst a bit. I see sometimes the compiler warns me about an API and suggests this fix:   if (@available(macCatalyst 15.0,*)) { /// Use API for this version of catalyst.... } And when I switch back to run on an iOS device the warning comes back and this time I get the suggestion: if (@available(iOS 15.0, *)) { //iOS 15 } If I just use the @available iOS 15 check and remove the macCatalyst check the compiler stops warning me when I try building on my Mac and on iOS, but the same isn't true the other way around (if I have code inside the macCatalyst version check, switching to build for an iOS device still warns me). I was expecting that code inside the if @available(macCatalyst 15,*) statement would only run on Mac catalyst if the version of macOS supports the API, but would not run on iOS at all (even if the API is available there too) but I still get compiler warnings on iOS and a suggestion for an extra if (@available(iOS 15.0, *)) which produces the following:  if (@available(macCatalyst 15.0,*))     {         if (@available(iOS 15.0, *))         { //do something iOS 15 and later...and macCatalyst 15 and later. } } What do I make of the macCatalyst availability check? It comes up in code completion but just using the iOS check seems like the correct way (it silences compiler warnings but I haven't tested on an older version of macOS to see if using any of this API would produce a crash). I conclude that if (@available(iOS 15.0, )) should be used pretty much always instead of if (@available(macCatalyst 15.0,)) and if I need code only for Mac Catalyst I should check the TARGET_OS_MACCATALYST macro instead:  #if TARGET_OS_MACCATALYST #else //iOS only #endif Is that correct?
1
0
1.3k
Oct ’22
Window's title bar separator draws way out of place on Mac Catalyst, not even close to title bar location
So I built my app with Mac Catalyst. I see this little line appear and disappear periodically in the window. Then all of a sudden it disappears when the window's activation state changes sometimes. It looks like a weird little glitch. Turns out this is the title bar's separator which is UITitlebarSeparatorStyleAutomatic (I believe the system hides/shows the separator in this mode based on current window states. I change the separator style to shadow and sure enough it draws like a shadow and never disappears. It's not even close to where the separator is supposed to be (nowhere near the title bar). The only workaround I have is to use UITitlebarSeparatorStyleNone which I'll do if I have to but was wondering if someone else has run into this and has a better workaround.
5
2
1.1k
Oct ’22
Mac Catalyst When to Handle Setting Min/Max Size for UISplitViewController columns? Window Resize Event?
Trying to use UISplitViewController. Since this app can be run on many different monitor sizes I want to allow the splits to be resized reasonably. There is this API: //Allow setting the primary column width with point values. This is especially useful in Catalyst where the window may be resized more often. // If set to non-Automatic, takes precedence over preferredPrimaryColumnWidthFraction. @property(nonatomic, assign) CGFloat preferredPrimaryColumnWidth API_AVAILABLE(ios(14.0)); // default: UISplitViewControllerAutomaticDimension > > @property(nonatomic, assign) CGFloat minimumSupplementaryColumnWidth API_AVAILABLE(ios(14.0)); @property(nonatomic, assign) CGFloat maximumSupplementaryColumnWidth API_AVAILABLE(ios(14.0)); // An animatable property that can be used to adjust the minimum absolute width of the primary view controller in the split view controller. @property(nonatomic, assign) CGFloat minimumPrimaryColumnWidth API_AVAILABLE(ios(8.0)); // default: UISplitViewControllerAutomaticDimension // An animatable property that can be used to adjust the maximum absolute width of the primary view controller in the split view controller. @property(nonatomic, assign) CGFloat maximumPrimaryColumnWidth API_AVAILABLE(ios(8.0)); // default: At what point in time should I be changing the preferredPrimaryColumnWidth, the min/and max width values? What event? If I was in Appkit I could maybe use something like NSWindowDidResizeNotification, then compute min/max sizes for each column based off the current window size (but I think NSSplitView gives the delegate an opportunity to control constraining column sizes if I remember correctly so I don't think that it would necessary to listen for a window resize event). I find the default sizes set by UISplitViewController to be insufficient (I want to allow users to size columns wider). Ideally this would be easier if there was minimumPrimaryColumnFraction and maxPrimaryColumnFraction. Then I just set the min/max fractions once to reasonable values and not worry about changing them on window resize. But since we can only set min/max with a hardcoded point size it seems more complicated?
0
1
523
Oct ’22
Unable to get CloudKit sync Notifications on Mac Catalyst Build -application:didFailToRegisterForRemoteNotificationsWithError: is being called
Working on a Mac Catalyst version of one of my apps. I noticed making changes on my iPhone (debug environment) aren't being pushed to my Mac (also in debug environment). Then when I quit and relaunch the app and manually force an iCloud sync at launch I get all the changes. At app launch I see the following method is being called on my AppDelegate after I attempt to register remote notifications: -application:didFailToRegisterForRemoteNotificationsWithError: with the error: Notifications are not allowed for this application" UserInfo={NSLocalizedDescription=Notifications are not allowed for this application}. Anyone experience this and have a solution? Under "Signing and Capabilities" I see an entry for Push Notifications for iOS and macOS.
1
0
947
Oct ’22
UIKitCore -[UIResponder doesNotRecognizeSelector:] crashes since IOS 15.7
Since iOS 15.7 these crash reports have started appearing: 0   CoreFoundation                0x18043bd1c __exceptionPreprocess + 216 (NSException.m:200) 1   libobjc.A.dylib               0x197c60ee4 objc_exception_throw + 56 (objc-exception.mm:565) 2   CoreFoundation                0x18050c75c -[NSObject(NSObject) doesNotRecognizeSelector:] + 140 (NSObject.m:147) 3   UIKitCore                     0x18359320c -[UIResponder doesNotRecognizeSelector:] + 268 (UIResponder.m:685) 4   CoreFoundation                0x1803d561c forwarding + 1472 (NSForwarding.m:3577) 5   CoreFoundation                0x1803d482c _CF_forwarding_prep_0 + 92 6   CoreFoundation                0x1803d22e8 CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER + 20 (CFNotificationCenter.c:652) 7   CoreFoundation                0x1804678e4 ___CFXRegistrationPost_block_invoke + 48 (CFNotificationCenter.c:173) 8   CoreFoundation                0x18043cc04 _CFXRegistrationPost + 416 (CFNotificationCenter.c:199) 9   CoreFoundation                0x1803e7070 _CFXNotificationPost + 708 (CFNotificationCenter.c:1147) 10  Foundation                    0x181ad704c -[NSNotificationCenter postNotificationName:object:userInfo:] + 92 (NSNotification.m:560) 11  UIKitCore                     0x182a9ac08 -[UIScene _invalidate] + 664 (UIScene.m:942) 12  UIKitCore                     0x182c2765c -[UIWindowScene _invalidate] + 160 (UIWindowScene.m:334) 13  UIKitCore                     0x182991f34 -[UIApplication workspace:willDestroyScene:withTransitionContext:completion:] + 216 (UIApplication.m:3999) 14  UIKitCore                     0x1829291a0 -[UIApplicationSceneClientAgent scene:willInvalidateWithEvent:completion:] + 360 (UIApplicationSceneClientAgent.m:61) 15  FrontBoardServices            0x1915b79d8 -[FBSScene _callOutQueue_agent_willDestroyWithTransitionContext:completion:] + 256 (FBSScene.m:456) 16  FrontBoardServices            0x1915bf810 __84-[FBSWorkspaceScenesClient _queue_invalidateScene:withTransitionContext:completion:]_block_invoke_2 + 100 (FBSWorkspaceScenesClient.m:622) 17  FrontBoardServices            0x1915a3bdc -[FBSWorkspace _calloutQueue_executeCalloutFromSource:withBlock:] + 232 (FBSWorkspace.m:352) 18  FrontBoardServices            0x1915b5470 __84-[FBSWorkspaceScenesClient _queue_invalidateScene:withTransitionContext:completion:]_block_invoke + 280 (FBSWorkspaceScenesClient.m:621) 19  libdispatch.dylib             0x1800fc094 _dispatch_client_callout + 16 (object.m:560) 20  libdispatch.dylib             0x18009f150 _dispatch_block_invoke_direct$VARIANT$mp + 220 (queue.c:501) 21  FrontBoardServices            0x1915a52ac FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK + 40 (FBSSerialQueue.m:157) 22  FrontBoardServices            0x1915a47c0 -[FBSSerialQueue _targetQueue_performNextIfPossible] + 176 (FBSSerialQueue.m:181) 23  FrontBoardServices            0x1915a8960 -[FBSSerialQueue _performNextFromRunLoopSource] + 24 (FBSSerialQueue.m:194) 24  CoreFoundation                0x18045c4fc CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 24 (CFRunLoop.c:1972) Looks like all system code. Anyone else running into these since iOS 15.7?
Topic: UI Frameworks SubTopic: UIKit Tags:
12
4
4.1k
Oct ’22
UICollectionView List Style on Mac Catalyst: Prevent the Collection View From Changing the Selection when the Selected Row's Parent is Collapsed?
I'm using UICollectionView with a list style on Mac (looks like NSOutlineView in a sidebar). I have expandable rows. So this is the behavior I'm after: -If the user has a row selected, but decides to collapse the selected row's parent, I want to maintain the current selection. Instead this is what happens by default: -If a row selected and I collapse the parent the collection, the collection view automatically selects another row (in my case the first row at index path 0-0). Just because the user collapses the parent doesn't mean the selection should change. For instance in Xcode's Navigator I can have a file selected in a Group and collapse the group without modifying the current selection.
2
0
617
Oct ’22
UINavigationController inside UISplitViewController's UISplitViewControllerColumnSupplementary Doesn't Appear on Mac Catalyst
Working on a Mac Catalyst app. I have a UInavigationController. On iOS this is full screen but on Mac Catalyst I'm using it inside a UISplitViewController in the supplementary column. This view controller's root view controller has a navigationItem which configures a UISearchController. The search bar is nowhere to be found unless I set it to UINavigationItemSearchBarPlacementStacked. So is UINavigationItemSearchBarPlacementInline not supported for the supplementary column of a UISplitViewController? If that's the case I'm fine with that actually but there's got to be a way to make UINavigationItemSearchBarPlacementStacked look a little better on Mac? The search bar border is barely visible on a white background.
1
0
1.1k
Oct ’22
Disable vibrancy on titlebar/toolbar area of window on Mac Catalyst?
I can't seem to get rid of the "vibrancy" effect on the titlebar/toolbar area of the window on Mac Catalyst. I have a triple Split View controller. The primary vc style is sidebar in the split vc.. And that has the blur/visual effect and that's all well and good. But the title bar area on the supplementary column has the blur effect too and it looks kind of terrible (the navigation bar in the supplementary view controller has all of its navigationBar appearances configured with opaque content:   UINavigationBarAppearance *opaqueAppearance = [[UINavigationBarAppearance alloc]init];     [opaqueAppearance configureWithOpaqueBackground];     opaqueAppearance.backgroundEffect = nil;     opaqueAppearance.backgroundColor = [UIColor myColor]; //set to all appearances But I still get the blur effect on the navigation bar, which presumably is being mapped to NSToolbar. Is it possible to disable this blur effect for the column? It really doesn't look good in my app.
0
0
617
Oct ’22
Crash: Focus item <UITableViewCell> does not provide a parentFocusEnvironment.
I'm on Mac Catalyst. I have a UISearchController and I keep getting this crash after I clear the search bar, adjust the search scope segmented control if one of the UITableViewCells is focused (via arrow key press) before Focus item does not provide a parentFocusEnvironment. I can workaround the problem by overriding -parentFocusEnvironment, holding the parent UITableView in a property and returning it: -(id<UIFocusEnvironment>)parentFocusEnvironment { id<UIFocusEnvironment>theFocus = [super parentFocusEnvironment]; if (theFocus == nil) { return self.cachedParentFocus; } else { self.cachedParentFocus = theFocus } return theFocus; } The problem with this is it is likely to create a retain cycle (I did try a weak reference but that can cause the following crasher on deallocation (the focus environment continues to call this method on the table view cell even when its outside of a UIWindow): “Cannot form weak reference to instance (0x13799a000) of class UITableView. It is possible that this object was over-released, or is in the process of deallocation.” Anyone run into this and know of a potential workaround?
1
0
970
Oct ’22