ios – UIAlertController无法满足约束

ios – UIAlertController无法满足约束,第1张

概述我正在使用UIAlertController转换我的所有UIActionSheet和U​​IAlertView. 我的问题是当我尝试呈现样式ActionSheet的UIAlertController时. 这是我的代码: UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Title" 我正在使用UIAlertController转换我的所有UIActionSheet和U​​IAlertVIEw.

我的问题是当我尝试呈现样式ActionSheet的UIAlertController时.
这是我的代码:

UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Title"                                                               message:@"My message"                                                        preferredStyle:UIAlertControllerStyleActionSheet];UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:nil];[alert addAction:cancelAction];UIAlertAction *OKAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:nil];[alert addAction:OKAction];UIAlertAction *destroyAction = [UIAlertAction actionWithTitle:@"Destroy" style:UIAlertActionStyleDestructive handler:nil];[alert addAction:destroyAction];UIPopoverPresentationController *popPresenter = [alert popoverPresentationController];popPresenter.sourceVIEw = self.vIEw;popPresenter.sourceRect = self.vIEw.bounds;[self presentVIEwController:alert animated:YES completion:nil];

这是错误:

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) (    "<NSLayoutConstraint:0x7c00ab40 H:[UIVIEw:0x7c0764c0(304)]>","<NSLayoutConstraint:0x7b6c7f80 _UIAlertControllerVIEw:0x7b6c2e50'Title'.wIDth >= UIVIEw:0x7b6c3230.wIDth>","<NSLayoutConstraint:0x7ccdfe40 _UIAlertControllerVIEw:0x7b6c2e50'Title'.wIDth == UIVIEw:0x7b6efbe0.wIDth>","<NSautoresizingMaskLayoutConstraint:0x7c33b9d0 h=--& v=--& H:[UIVIEw:0x7c1094e0(0)]>")Will attempt to recover by breaking constraint <NSLayoutConstraint:0x7c00ab40 H:[UIVIEw:0x7c0764c0(304)]>

谢谢你们.

解决方法 我在目前的样式ActionSheet的UIAlertController中也遇到了类似的问题.

另一个可能的原因是错误地设置了UIPopoverPresentationController的allowedArrowDirections.在我的例子中,popover的sourceVIEw位于顶部,但我已将allowedArrowDirections设置为UIPopoverArrowDirectionDown,这会导致“无法同时满足约束”错误.将其设置为UIPopoverArrowDirectionUp后,错误消失了.

总结

以上是内存溢出为你收集整理的ios – UIAlertController无法满足约束全部内容,希望文章能够帮你解决ios – UIAlertController无法满足约束所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1003761.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-22
下一篇 2022-05-22

发表评论

登录后才能评论

评论列表(0条)

保存