UIViewAlertForUnsatisfiableConstraints when presen

2019-07-21 05:26发布

UIAlertController *alert =
[UIAlertController alertControllerWithTitle:@"What would you like to do?"
                                    message:@""
                             preferredStyle:UIAlertControllerStyleActionSheet];

[alert addAction:...] //left out for brevity of post

UIPopoverPresentationController *pop = [alert popoverPresentationController];
pop.sourceView = self.view;
pop.sourceRect = self.view.frame;
pop.permittedArrowDirections = UIPopoverArrowDirectionAny;

[self presentViewController:alert
                   animated:true
                 completion:^{
                 }];

The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in may also be helpful. 2014-10-22 13:33:17.966 Project[2995:40175] Unable to simultaneously satisfy constraints. Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints) ( "=44)]>", "", "", "", "" )

Will attempt to recover by breaking constraint =44)]>

What does this mean? What is the >=44?

I am just trying to present an UIAlertController on iPad, iOS8

2条回答
地球回转人心会变
2楼-- · 2019-07-21 05:54

I'd like to simply comment, but the stupid reputation system won't allow me to yet.

Simply setting a breakpoint on UIViewAlertForUnsatisfiableConstraints doesn't help, because it's the UIAlertController that's causing the problem, it's not the user's problem. It's an Apple bug and should be reported. I get this too. Works fine on iPhone sized devices, but fails like the above on iPad sized devices.

I just got mine to work by not specifying the entire source view's bounds as the sourceRect, but instead made a small rect at the gesture's location in the source view:

CGPoint     loc = [ges locationInView:self.view];
CGRect      popBox = CGRectMake(loc.x - 10, loc.y - 10, 20, 20);

popoverPresentationController.sourceRect = popBox;
查看更多
看我几分像从前
3楼-- · 2019-07-21 05:56

You'll want to add a Symbolic Breakpoint. Apple provides an excellent guide on how to do this.

Open the Breakpoint Navigator cmd+7

Click the Add button in the lower left

Select Add Symbolic Breakpoint...

Where it says Symbol just type in UIViewAlertForUnsatisfiableConstraints You can also treat it like any other breakpoint, turning it on and off, adding actions, or log messages.

查看更多
登录 后发表回答