autolayout

AutoLayout~Label

杀马特。学长 韩版系。学妹 提交于 2019-12-21 01:11:29
使用Autolayout可以不用计算文字的宽高,直接给label赋值,label会自己适应文字的长度调节宽高 如果你像下图一样限定了label的topMargin和左右边距 下边距设置为>=300 然后在ViewDidLoad里面重新给label设置内容,这时候你会发现,Label会自动变高 dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ _label.text = @"aaaaaaaaaaaasfeaqrgrthrwthwrtyjhwryjwryjwryjwryjwryjwryjwryjwrytjwryjwrytjwrytjwrtjwrtyjwrtjwrtjqwrtjwrtjhwrtjhetjrthjqwrthjqrthqrthjqrtjhqrtjhqarthjqethjteqathqtehqthqathqrthqrtjhq"; }); 此外Label还提供了一个属性preferredMaxLayoutWidth 用来获取计算文本高度是所用的宽度,如果这个属性没有设置就会按照autoLayout里的设置来计算 如果这个属性重新设置了值,就会使用这个值来计算label要变成的高度 将上面的代码改成下面的代码

Why is the top layout guide moving in my iMessage extension

五迷三道 提交于 2019-12-20 21:02:33
问题 I have an iMessage extension and I'm having some issues with the top layout guide. I have an MSMessagesAppViewController that handles changes between presentation styles. In my extension I have a button. When it is clicked I transition to expanded presentation style and then present a view controller modally. Here's the problem: my UI in the second VC is getting hidden behind the top navigation bar. I thought this was strange as I set my constraints to the top layout guide. So I dug through

UICollectionViewCell dynamic sizing for 4.4 and 5.5 inch

穿精又带淫゛_ 提交于 2019-12-20 18:58:10
问题 I have UICollectionView with cells in the storyboard. The size of each cell is set to 145x145. They look good on the iPhone 4 - 5s, but the size doesn't increase proportionally on the iPhone 6 and 6+. Rather than manually setting a different cell size for each device, how can I do it dynamically? See examples here: iPhone 5S: http://prntscr.com/55vy7q, iPhone 6: http://prntscr.com/55vyy2 回答1: If you want your cells to adjust their width, you'll need to calculate the flow layout's itemSize

UICollectionView with autosizing cells incorrectly positions supplementary view

ⅰ亾dé卋堺 提交于 2019-12-20 18:42:31
问题 I am using a UICollectionView with a Flow Layout and trying to get the collectionView to size the cells appropriately according to AutoLayout constraints. While the cells work as intended, I am running in to issues with the layout of any supplementary views that I add to the CollectionView. Specifically, the supplementaryView will be in the wrong position (i.e., the y origin is incorrect) on initial layout, before 'correcting' itself after I scroll. For reference, here is how I am configuring

UICollectionView with autosizing cells incorrectly positions supplementary view

落花浮王杯 提交于 2019-12-20 18:42:11
问题 I am using a UICollectionView with a Flow Layout and trying to get the collectionView to size the cells appropriately according to AutoLayout constraints. While the cells work as intended, I am running in to issues with the layout of any supplementary views that I add to the CollectionView. Specifically, the supplementaryView will be in the wrong position (i.e., the y origin is incorrect) on initial layout, before 'correcting' itself after I scroll. For reference, here is how I am configuring

UICollectionView with autosizing cells incorrectly positions supplementary view

大城市里の小女人 提交于 2019-12-20 18:42:11
问题 I am using a UICollectionView with a Flow Layout and trying to get the collectionView to size the cells appropriately according to AutoLayout constraints. While the cells work as intended, I am running in to issues with the layout of any supplementary views that I add to the CollectionView. Specifically, the supplementaryView will be in the wrong position (i.e., the y origin is incorrect) on initial layout, before 'correcting' itself after I scroll. For reference, here is how I am configuring

ScrollView has ambiguous scrollable content height [duplicate]

折月煮酒 提交于 2019-12-20 17:34:28
问题 This question already has answers here : UIScrollView Scrollable Content Size Ambiguity (30 answers) Closed 5 years ago . I am making a very basic UIScrollView test. Here is my setup It shows me the following AutoLayout error: ScrollView has ambiguous scrollable content height 回答1: You need to ensure you've got a chain of vertical spacing constraints from the top of the scroll view through all your elements to the bottom of the scroll view. Once you do that, your warning/error should go away.

ScrollView has ambiguous scrollable content height [duplicate]

和自甴很熟 提交于 2019-12-20 17:32:45
问题 This question already has answers here : UIScrollView Scrollable Content Size Ambiguity (30 answers) Closed 5 years ago . I am making a very basic UIScrollView test. Here is my setup It shows me the following AutoLayout error: ScrollView has ambiguous scrollable content height 回答1: You need to ensure you've got a chain of vertical spacing constraints from the top of the scroll view through all your elements to the bottom of the scroll view. Once you do that, your warning/error should go away.

How to disable “Relative to margin” option for newly created constraint in Xcode6

China☆狼群 提交于 2019-12-20 16:21:08
问题 I want to disable automatic adding Relative to margin when creating constraints in IB of Xcode 6 . It's nice that they turn this option on by default, but I have to support iOS7 , so it turned out I have to manually disable this option every time after adding new constraint. I found this setting for disabling it beforehand, but it's always on by default. 回答1: This plugin will set a default value of Constrain to margins to disabled. https://github.com/mshibanami/DefaultMarginDisabler 回答2: The

How to disable “Relative to margin” option for newly created constraint in Xcode6

≯℡__Kan透↙ 提交于 2019-12-20 16:20:35
问题 I want to disable automatic adding Relative to margin when creating constraints in IB of Xcode 6 . It's nice that they turn this option on by default, but I have to support iOS7 , so it turned out I have to manually disable this option every time after adding new constraint. I found this setting for disabling it beforehand, but it's always on by default. 回答1: This plugin will set a default value of Constrain to margins to disabled. https://github.com/mshibanami/DefaultMarginDisabler 回答2: The