Hi all
When running the following code on macOS Ventura, I get the error below: (At least in a Catalyst app running on macOS.)
Code to reproduce:
NSString *message = @"1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20";
UIAlertController* alert = [UIAlertController alertControllerWithTitle:@"My Alert" message:message preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* yesAction = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {}];
[alert addAction:yesAction];
UIAlertAction* noAction = [UIAlertAction actionWithTitle:@"No" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {}];
[alert addAction:noAction];
[self presentViewController:alert animated:YES completion:nil];
Error:
[Layout] Unable to simultaneously satisfy constraints:
(
"<NSLayoutConstraint:0x60000265caa0 _NSAlertContentView:0x7fc0600390a0.trailingMargin == NSTextField:0x7fc06003a900.trailing (active)>",
"<NSLayoutConstraint:0x60000265c9b0 _NSAlertImageView:0x7fc06003a460.leading == _NSAlertContentView:0x7fc0600390a0.leadingMargin (active)>",
"<NSLayoutConstraint:0x60000265ca50 H:[_NSAlertImageView:0x7fc06003a460]-(10)-[NSTextField:0x7fc06003a900] (active)>",
"<NSLayoutConstraint:0x60000265ca00 _NSAlertImageView:0x7fc06003a460.width == 64 (active)>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x60000265ca50 H:[_NSAlertImageView:0x7fc06003a460]-(10)-[NSTextField:0x7fc06003a900] (active)>
It looks like the error happens as soon as the message is displayed with scrollbar on older macOS versions.
This is an issue only on macOS Ventura. It works fine on iOS and older macOS, but freezes the app on macOS Ventura.
It seems to be not only with many lines, but also with a long message. See here: https://stackoverflow.com/questions/74256830/multi-line-uialertcontroller-freezes-on-macos-ventura
In the mean time I also opened an Apple DTS ticket with my sample code above and the engineer confirmed that this is an Apple bug an I should file bug report.