iOS 自定义视图:无法同时满足约束错误 [英] iOS custom view: Unable to simultaneously satisfy constraints error

查看:28
本文介绍了iOS 自定义视图:无法同时满足约束错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在关注 Ray Wenderlich 关于实现 rateView 的教程:http://www.raywenderlich.com/1768/how-to-make-a-custom-uiview-a-5-star-rating-view

I am following Ray Wenderlich's tutorial on implementing a rateView: http://www.raywenderlich.com/1768/how-to-make-a-custom-uiview-a-5-star-rating-view

在我的应用程序中实现 rateView 后,我收到此错误:

After implementing a rateView into my app, I got this error:

无法同时满足约束条件.可能以下列表中的至少一项约束是您不想要的.试试这个: (1) 查看每个约束并尝试找出您不期望的;(2) 找到添加不需要的约束或约束的代码并修复它.(注意:如果看到 NSAutoresizingMaskLayoutConstraints 看不懂,请参考 UIView 属性 translatesAutoresizingMaskIntoConstraints 的文档)

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)

("NSAutoresizingMaskLayoutConstraint:0x870c2b0 h=--& v=--& V:[UIView:0x93a1d60(416)]","NSLayoutConstraint:0x87363c0 V:|-(203)-[RateView:0x8729040] (Names: '|':UIView:0x93a1d60)",NSLayoutConstraint:0x8736440 V:[RateView:0x8729040]-(228)-|(名称:'|':UIView:0x93a1d60)")

( "NSAutoresizingMaskLayoutConstraint:0x870c2b0 h=--& v=--& V:[UIView:0x93a1d60(416)]", "NSLayoutConstraint:0x87363c0 V:|-(203)-[RateView:0x8729040] (Names: '|':UIView:0x93a1d60 )", "NSLayoutConstraint:0x8736440 V:[RateView:0x8729040]-(228)-| (Names: '|':UIView:0x93a1d60 )" )

将尝试通过打破约束来恢复NSLayoutConstraint:0x8736440 V:[RateView:0x8729040]-(228)-|(名称:'|':UIView:0x93a1d60)

Will attempt to recover by breaking constraint NSLayoutConstraint:0x8736440 V:[RateView:0x8729040]-(228)-| (Names: '|':UIView:0x93a1d60 )

中断 objc_exception_throw 以在调试器中捕获它.UIKit/UIView.h 中列出的 UIView 上的 UIConstraintBasedLayoutDebugging 类别中的方法也可能会有所帮助.

Break on objc_exception_throw to catch this in the debugger. The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in UIKit/UIView.h may also be helpful.

我下载了 Ray 提供的示例应用,它非常适合我,没有错误.查了下代码,没看出来有什么不同,我在Interface Builder中的连接也和他一样.一个显着差异是我们个人费率视图的尺寸检查器.他的样子是这样的:

I downloaded the sample app that Ray provides, and it works perfectly for me, no errors. After searching through code, I don't see any differences, and my connections in Interface Builder are the same as his. The one significant difference was in the size inspector for our individual rate views. His looks like this:

虽然我的看起来像这样:

while mine looks like this:

考虑到错误与约束有关,这可能是问题所在.但是,我不知道如何将我的 rateview 更改为 autoresizing 之类的 Ray's.帮助?

Considering that the error has to do with constraints this is probably the issue. However, I have no clue how to change my rateview to be autoresizing and such like Ray's. Help?

推荐答案

取消选中使用自动布局"并尝试....

Uncheck "Use Autolayout" and try....

这篇关于iOS 自定义视图:无法同时满足约束错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆