Xcode 13 iOS 15 Programmatic Obj-C Constraints translatesAutoresizingMaskIntoConstraints - ios

I use 100% programmatic constraints in my interface code. Upgraded to Xcode 13 and iOS 15. Got tons of NEW execution warnings about constraints, all saying that the system had to break some constraints to comply with others. I had not seen such warnings for several years, and have not touched my constraint code in all that time. Yet thorough testing shows my code continues to run correctly. What's up?

Answer: I had been a bit cavalier with the timing of when iOS actually calculated the constrained dimensions. I put all of my programmatic interface declarations into a single method. At the bottom of that method, I have long had code that went beyond interface layout, into NavCon preliminaries. Among those NavCon declarations, I had lines like:
self.view_D0_Tutorial.frame = self.view_CenterPane_D0_Tutorial.frame;
I noted at the time that I wrote and debugged those lines, that using the debugger to ask what the location data was, all I ever got was CRect (0,0,0,0), yet the code somehow did the right thing.
Well, in the upgrade, iOS apparently changed the way they do things. I had to do two things in response.
(1) moved all the NavCon preliminary code to a new separate method, and call it with performSelector and 0 delay.
(2) changed the simple frame assignment to a more limited assignment:
self.view_D0_Tutorial.frame = CGRectMake(0, 0, self.view_CenterPane_D0_Tutorial.frame.size.width, self.view_CenterPane_D0_Tutorial.frame.size.height);;
The combination made the error messages go away, and my code continues to run correctly!

Related

App crashes with [ServicesDaemonManager] interruptionHandler is called. -[FontServicesDaemonManager connection]_block_invoke

My App crashes randomly with this error:
[ServicesDaemonManager] interruptionHandler is called.
-[FontServicesDaemonManager connection]_block_invoke
(didReceiveMemoryWarning fires before the error message)
It is a bit hard to post code because of the randomness.
I use SwiftUI (UIHostingController), #ObserverObjects, async network calls, transitions to other views, etc.
It all works fine most of the time but sometimes i ran into this error.
The memory is then increasing constantly until the app crashes.
I tried to fix all possible memory leaks (to deallocate all images, [weak self], ...)
didn't help.
I'am not sure what the FontServicesDaemonManager is doing and in what way it is involved but all fonts are using the system font:
.font(Font.system(size: 25 , weight: .regular))
Sometimes also this error appears right after the one from obove:
-[UIWindow endDisablingInterfaceAutorotationAnimated:] called on <UIWindow: 0x10aab11a0; frame = (0 0; 375 812); gestureRecognizers = <NSArray: 0x10acb2510>; layer = <UIWindowLayer: 0x10aacbee0>> without matching -beginDisablingInterfaceAutorotation. Ignoring.
Anyone ran into similar issues or has an idea how to fix this?
(Xcode 11.6)
Update:
This problem is usually related to Autolayout constraints. Please check your constraints of all related views.
Hope you got the answer, I am here describing my scenario:
I got the same error with Xcode 11.6, the issue was I had enabled the zoombie object on scheme & it was creating [ServicesDaemonManager] interruptionHandler. So please check it. Reason behind memory warning was loading of high resolution images on mail thread which was not good. Adding download image in background thread worked for me.
Thanks,
Ratneshwar
This problem is usually related to constraints, there must be some ambiguity with your constraints, that's why you are getting this error.
Had the same issue with one of my collection views, because the constraints were not properly set for smaller screens. Check the constraints again and you will be good to go.
The problem i had was related to Autolayout and some constraints that did work for fullscreen for a specific view. I changed the Autolayout constraints and since then i had no crashes related to this issue anymore..

Weird padding at top UINavigationController while animating to detail in iOS11

I'm posting here because I'm completely lost on this one.
I've searched all over the web, tried a lot of things myself, and searched weeks on this bug, but I can't find it.
So ever since iOS 11 (doesn't happen on iOS 10), everytime I press a button that activates the "show" segue in a UINavigationController the animation shows some weird padding at the top.
This padding disappears when the animation is finished.
I've changed the backgroundcolor of the superview to a red color, and the space you can see is indeed from the superview itself, so my guess is the whole UITableView is being moved down for some reason, although I'm not sure what exactly is the cause here.
(I'm using storyboard and AutoLayout constraints)
Another thing I noticed is that the spacing/padding you see is different on the iPhone X compared to the other devices (my guess is that it's the same height as the (non)safe area at the top? Again, not sure.
I don't think code is necessary to be provided here, as I wouldn't really know which part causes this behaviour (and there's a lot of code that I can't share for reasons..).
Any suggestions/help on how to fix this would be deeply appreciated!
Here are some examples:
iPhone X running iOS 11.1 (also happened on 11.0)
iPhone 8 gif
EDIT: I should add, some things I already tried:
tableView.contentInsetAdjustmentBehavior = .never
Setting headerviews to 0
tableView.setContentOffset(0, animated: false)
Playing with the translucency settings of the UINavigationBar
AutomaticallyAdjustContentInsets is set to false
So, as suggested by Spenser-Arn, I played around with the constraints and the Safe Areas, turns out, the safe areas where the cause of the issue.
Hope this helps other people as much as it helped me, and a big thankyou to Spenser-Arn!

iOS 10 UIKit Zombie Crash, Worked Fine in iOS 7-9

We've got an app that's fairly large now, and we recently upgraded to iOS 10. In doing so, a new bug was introduced, and we're at a loss for how to solve it.
The crash itself occurs during a call to layoutIfNeeded(). However, the crash does not occur unless the layoutIfNeeded() call is contained inside a UIView.animateWithDuration() block. No amount of weak referencing, delays, or dispatch calls seems to have any effect. The same crash can be triggered during a call to [super viewWillTransitionToSizeWithTransitionCoordinator].
"An Objective-C message was sent to a deallocated 'Bubble' object (zombie) at address: 0x10924f030."
Enabling Zombies shows that we have a Release call going to one of our UIView subclasses, which we've named Bubble. Nothing too special there, some layout constraints and a gesture recognizer.
The Instruments app hasn't helped much, nor has the new visual memory debugger in Xcode 8 (though it is awesome, surprisingly little documentation on the feature).
I've included a screenshot of Zombies during the crash here. While I know the retain count can be misleading, there are certainly some confusing points to the trace, and we could really use some help diagnosing this.
Again, this code worked fine before iOS 10. We've been unable to find any notes from Apple about underlying changes to UIKit that may have had an effect.
Some more brief info: [Bubble cleanBubbles] simply iterates over the subviews of any view passed in, and removes the subview if its a Bubble class.
Apologies on certain violations of naming conventions, I'm sure there's plenty to criticize!
Thanks

Indentation of UITableViewCell changes after rotation only on iOS 8

I have an UITableView with three dynamic rows. When displaying the UITableViewController the first time everything works fine. After a rotation the rows which have a data in it get an indentation despite I set setLayoutMargins to zero. I cannot reproduce this issue in another project until now. It is only appearing in iOS 8 but but only on one table. The same source for the table is working in a test project without problems. The only difference here is that it is in a container with some other views.
I checked auto layout constraints, the rotation methods, commented things out - all without success. The change of the indentation occurs between willRotateToInterfaceOrientation and didRotateToInterfaceOrientation or after viewWillTransitionToSize. I even updated to iOS 8.1 with the same results.
Has someone expeerienced a similar behavior?
PS:
What I've also noticed that when setting the layout margins to zero on iOS 8 the animation is not as smooth as it would be with the default values (with indentation). On iOS 7 the animation is always smooth.
EDIT:
I tracked some things down. If a UITableViewController is embedded into an UINavigationController the indentation happens on rotation. If you rotate further it goes back to it's set indentation (no indentation in my case).
If the UITableViewController is embedded into a container (and this container is in a navigation controller) than after the rotation the cell get it's default indentation back. If you rotate further this behavior stays the same (always indented).
Are some events not send to the child view controller or none of you uses a UITableViewController embedded into an UINavigationController?
In my opinion it is a iOS 8 Bug or a Xamarin Bug. Perhaps one other could verify if it is the same with his installation. I'm using Xamarin Studio 5.5.2 with Xcode 6.1.
One ugly solution to this is this:
public override void DidRotate (UIInterfaceOrientation fromInterfaceOrientation)
{
base.DidRotate (fromInterfaceOrientation);
// otherwise cells are indented! iOS 8 Bug?
TableView.ReloadData ();
}
One could use reloadData or reloadSection in didRotateFromInterfaceOrientation, despite it is a deprecated function. But there is no viewDidTransitionToSize and I also have to support iOS 7.
Edit:
Another solution I have come up with is to draw a custom separator line. This only works for iOS 8 and would answer the question (despite I've another issue on iOS 7 where this approach doesn't help).

Suspend redrawing while changing multiple children

I have a UIViewController that after asynchronously loading some data needs to resize some child views (Some UITableViews, and some UIScrollViews). This works just fine in the simulator, but on an actual device, it hangs for a long time (as much as 30 seconds in one case). I think the problem is that it wants to recalculate everything after each changed to the child view and I would like to be able to tell it to defer any recalculations until I've resized everything, but I'm drawing a blank on finding a way to do that. Is there a mechanism to do this?
So what I'm doing is something like this (I'm using C# with Xamarin but input in Obj-C would also be appreciated!):
// Need to suspend layout here...
MyTable.Frame = new RectangleF(...);
SomeOtherTable.Frame = new RectangleF(...);
ScrollView.ContentSize = new SizeF(...);
AnotherScrollView.ContentSize = new SizeF(...);
AnotherScrollView.Frame = new RectangleF(...);
// Ok - now you can redraw!
Update: Jacob's suggestion of disabling animation didn't seem to help, but I think I've isolated the problem to the table resizing. They seem to have the biggest impact on performance, but I'm not sure why, or how to mitigate the problem. I may follow up with a separate question on that.

Resources