objective-c – 在iOS 8Xcode 6 GM Seed上使用autolayout大小时,UIScrollView会中断

objective-c – 在iOS 8Xcode 6 GM Seed上使用autolayout大小时,UIScrollView会中断,第1张

概述如何使用自动布局来计算其内容大小? 每当Scroll视图(带有Autolayout)存在时,Xcode 6似乎会创建一个“UIView Encapsulated Layout Height”约束,并且此约束将强制将高度设置为帧高度(从而使滚动视图的滚动功能无效). 错误: 2014-09-09 21:06:01.059 ScrollViewLayoutBreaking[24488:88731] U 如何使用自动布局来计算其内容大小?

每当Scroll视图(带有autolayout)存在时,Xcode 6似乎会创建一个“UIVIEw Encapsulated Layout Height”约束,并且此约束将强制将高度设置为帧高度(从而使滚动视图的滚动功能无效).

错误:

2014-09-09 21:06:01.059 ScrollVIEwLayoutBreaking[24488:88731] 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:0x7f9a19ebd150 V:[UIVIEw:0x7f9a19ea7f90(530)]>","<NSLayoutConstraint:0x7f9a19ec1370 V:[UIVIEw:0x7f9a19ebd5e0(110)]>","<NSLayoutConstraint:0x7f9a19ea9ee0 V:[_UILayoutGuIDe:0x7f9a19ec18d0]-(0)-[UIVIEw:0x7f9a19ea7f90]>","<NSLayoutConstraint:0x7f9a19ec1fa0 V:[UIVIEw:0x7f9a19ea7f90]-(0)-[UIVIEw:0x7f9a19ebd5e0]>","<NSLayoutConstraint:0x7f9a19e8d270 V:[UIVIEw:0x7f9a19ebd5e0]-(5)-[_UILayoutGuIDe:0x7f9a19ec2260]>","<_UILayoutSupportConstraint:0x7f9a19ea0ac0 V:[_UILayoutGuIDe:0x7f9a19ec18d0(0)]>","<_UILayoutSupportConstraint:0x7f9a19ea7380 V:|-(0)-[_UILayoutGuIDe:0x7f9a19ec18d0]   (names: '|':UIScrollVIEw:0x7f9a19ea76a0 )>","<_UILayoutSupportConstraint:0x7f9a19e21d00 V:[_UILayoutGuIDe:0x7f9a19ec2260(0)]>","<_UILayoutSupportConstraint:0x7f9a19e8a930 _UILayoutGuIDe:0x7f9a19ec2260.bottom == UIScrollVIEw:0x7f9a19ea76a0.bottom>","<NSLayoutConstraint:0x7f9a1c003f50 'UIVIEw-Encapsulated-Layout-Height' V:[UIScrollVIEw:0x7f9a19ea76a0(504)]>")Will attempt to recover by breaking constraint <NSLayoutConstraint:0x7f9a19ebd150 V:[UIVIEw:0x7f9a19ea7f90(530)]>Make a symbolic breakpoint at UIVIEwAlertForUnsatisfiableConstraints to catch this in the deBUGger.The methods in the UIConstraintBasedLayoutDeBUGging category on UIVIEw Listed in <UIKit/UIVIEw.h> may also be helpful.

编辑:此滚动视图中的所有视图都是自动循环的,并已固定到滚动视图的顶部和底部以及两侧.我知道未能在所有四个方面绑定它将无法创建内容大小. iOS 7 / XCode 5中的自动布局和滚动是正确的,但iOS 8 / XCode 6中完全相同的代码和故事板中断.

解决方法 通过你的截图,我猜你在滚动视图中使用自定义视图所以……

你的内容观点是:STH,Foo,bar,Baz,Qux,Blah,Woot,Lorem,Ipsum,Dolor

在代码中,您可以通过自动布局自动设置内容大小,方法是设置彼此相关的所有内容视图,但顶视图和底视图除外……这些视图必须与滚动视图的边缘相关,这是一个示例:

-(voID)example{UIVIEw *parentVIEw; //Can be the Scroll VIEw or the Scroll VIEw supervIEw,it's better for the ScrollVIEw to be the Owner of the restrictionsUIVIEw *prevIoUsVIEw;UIScrollVIEw *scrollVIEw;NSArray * arrayOfContentVIEws = @[STH,Dolor];for (UIVIEw * currentVIEw in arrayOfContentVIEws) {    //important for autolayout Restrictions    currentVIEw.translateautoresizingMask = NO;    [scrollvIEw addSubvIEw:currentVIEw];    if (prevIoUsVIEw == nil) {        //For the top,left and Right Attribute Edges of the ScrollVIEw        prevIoUsVIEw = scrollVIEw;        [parentVIEw addConstraint:[NSLayoutConstraint constraintWithItem:currentVIEw                                                               attribute:NSLayoutAttributetop                                                               relatedBy:NSLayoutRelationEqual                                                                  toItem:prevIoUsVIEw                                                               attribute:NSLayoutAttributetop                                                              multiplIEr:1.0                                                                constant:0.0]];        //10% of the scrollvIEw Frame Size (not Content Size)        [parentVIEw addConstraint:[NSLayoutConstraint constraintWithItem:currentVIEw                                                               attribute:NSLayoutAttributeHeight                                                               relatedBy:NSLayoutRelationGreaterThanorEqual                                                                  toItem:prevIoUsVIEw                                                               attribute:NSLayoutAttributeHeight                                                              multiplIEr:0.1                                                                constant:0.0]];                }else{        [parentVIEw addConstraint:[NSLayoutConstraint constraintWithItem:currentVIEw                                                               attribute:NSLayoutAttributetop                                                               relatedBy:NSLayoutRelationEqual                                                                  toItem:prevIoUsVIEw                                                               attribute:NSLayoutAttributeBottom                                                              multiplIEr:1.0                                                                constant:0.0]];        [parentVIEw addConstraint:[NSLayoutConstraint constraintWithItem:currentVIEw                                                               attribute:NSLayoutAttributeHeight                                                               relatedBy:NSLayoutRelationEqual                                                                  toItem:prevIoUsVIEw                                                               attribute:NSLayoutAttributeHeight                                                              multiplIEr:1.0                                                                constant:0.0]];    }    [parentVIEw addConstraint:[NSLayoutConstraint constraintWithItem:currentVIEw                                                           attribute:NSLayoutAttributeleft                                                           relatedBy:NSLayoutRelationEqual                                                              toItem:prevIoUsVIEw                                                           attribute:NSLayoutAttributeleft                                                          multiplIEr:1.0                                                            constant:0.0]];    [parentVIEw addConstraint:[NSLayoutConstraint constraintWithItem:currentVIEw                                                           attribute:NSLayoutAttributeRight                                                           relatedBy:NSLayoutRelationEqual                                                              toItem:prevIoUsVIEw                                                           attribute:NSLayoutAttributeRight                                                          multiplIEr:1.0                                                            constant:0.0]];    prevIoUsVIEw = currentVIEw;    }//Last VIEw Dolor to the Bottom Edge of the scrollVIEw[parentVIEw addConstraint:[NSLayoutConstraint constraintWithItem:prevIoUsVIEw                                                       attribute:NSLayoutAttributeBottom                                                       relatedBy:NSLayoutRelationEqual                                                          toItem:scrollVIEw                                                       attribute:NSLayoutAttributeBottom                                                      multiplIEr:1.0                                                        constant:0.0]];}
总结

以上是内存溢出为你收集整理的objective-c – 在iOS 8 / Xcode 6 GM Seed上使用autolayout大小时,UIScrollView会中断全部内容,希望文章能够帮你解决objective-c – 在iOS 8 / Xcode 6 GM Seed上使用autolayout大小时,UIScrollView会中断所遇到的程序开发问题。

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

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

原文地址: http://outofmemory.cn/langs/1239626.html

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

发表评论

登录后才能评论

评论列表(0条)

保存