autolayout

Ambiguity with two inequality constraints

好久不见. 提交于 2019-12-19 05:19:07
问题 I want to have the bottom view be at least 20 away from both the image and the label above it. The label is multiline, so it can be taller or shorter than the image view, depending on how much text there is. When I add two "distance to nearest neighbour >= 20" constraints like shown in the screenshot, Xcode tells me constraints are ambiguous. How do I fix it? 回答1: I think you can do it like this, if I understand your requirements: The image view has a fixed width and height, and constraints

ios auto-layout: Programmatically set width constraint

♀尐吖头ヾ 提交于 2019-12-19 05:08:08
问题 I am working on an ios application. I am adding the auto-layout programmatically to 2 labels. I need to add a constraint to make them equal width. I know how to fix the width of a label by using : constraint = [NSLayoutConstraint constraintWithItem:myLabel attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem: nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0f constant:200.0f]; That would fix the label size to a constant. But I have 2 labels and I want them to

Center a large UIView using NSLayoutConstraint

好久不见. 提交于 2019-12-19 04:58:15
问题 I am new to use Autolayouts, even this is my first try. Whatever I do with it, I end with a white screen as result. Here is my attempt. I have a UIView , let me say a parentView of frame (60, 154, 200, 200) . It is a subview to self.view . Then I have a dynamic view, say dynamicView of frame (0, 0, 260, 100) and a label of frame (15, 25, 230, 50) which is a subview to dynamicView . When I add the dynamicView as subview to the parentView , it goes out of parentView 's bounds. So, I'd like to

Xcode 4.5 storyboard crashing

≯℡__Kan透↙ 提交于 2019-12-19 04:38:16
问题 Very often when I try to edit UILabels in storyboard, Xcode is crashing. Any ideas what could be causing this? It looks like it has something to do with one of the autolayout constraints. Here's the error report: Process: Xcode [43938] Path: /Applications/Xcode.app/Contents/MacOS/Xcode Identifier: com.apple.dt.Xcode Version: 4.5 (1839) Build Info: IDEApplication-1839000000000000~3 App Item ID: 497799835 App External ID: 10747437 Code Type: X86-64 (Native) Parent Process: launchd [43283] Date

auto layout modify multiplier of constraint programmatically

≡放荡痞女 提交于 2019-12-19 04:09:07
问题 How can I modify the multiplier of a constraint programmatically? I have set the following: [self.view addConstraint:[NSLayoutConstraint constraintWithItem:_button attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeWidth multiplier:0.5 constant:0.0]]; and I need to modify it to this: [self.view addConstraint:[NSLayoutConstraint constraintWithItem:_button attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:self.view

Arrange 3 UIButtons(of equal width) side-by-side

血红的双手。 提交于 2019-12-19 02:53:09
问题 How to arrange 3 UIButtons side-by-side.I am using Auto-layout. My requirement is: 1.they should be equal width regardless of device 2.occupy vertically from starting to end of the view i tried different ways, i failed to achieve that. Is it possible through interface builder 回答1: There are 2 ways to do this. Way 1: With use of equal width constraint of button Select all 3 buttons and add top, left , right, height and equal width Way 2: With use of Stack view Step 1: Add 3 buttons. Step 2:

Autolayout and Device Orientation

风流意气都作罢 提交于 2019-12-19 02:27:15
问题 I am developing an application which supports portrait and landscape modes . I am using auto layout to arrange my views . As i have been reading many posts and i have realized that developers commonly use one among the following approaches. 1. First approach: Implement the UIViewController:updateConstraints method and update constraints according to device orientation. 2. Second approach: Implement the UIViewController:viewWillLayoutSubviews method and update constraints according to device

安卓屏幕适配框架的较量 dp & 限定符 & autolayout & autosize

巧了我就是萌 提交于 2019-12-18 20:46:03
安卓屏幕适配框架的较量 dp & 限定符 & autolayout & autosize 这里讲的是google自带的dp适配、比较久远的限定符适配、鸿神的autolayout、今日头条的autosize,下面大家就一起来看看他们的效果吧:(仅单一维度测试,数值也可能不标准,仅供参考,大家不要较真哦) 为了突出两个模拟器之间的差异明显,我们用的是1440*2560 和 480*800 分辨率的模拟器。下面所有图片,左边为1440*2560分辨率的模拟器,右边为480*800分辨率的模拟器。 首先上一个参考值,px的效果: 可见此图差异明显,两者都是100*100px的尺寸,也突出了px的特点:不同的设备不同的显示屏显示效果是相同的,这是绝对像素,是多少就永远是多少不会改变。 接下来测试dp的效果: dp的单位相对px来说就好一些,但是看起来还是能明显看出差别的,dp是google提出的适配方案,但是面对众多的机型,有时候也是不能满足我们的适配需求。 然后下面是传统的限定符适配方案,不多说,上效果: 这个很多兄弟们都用了好久,相当年我学安卓的时候就是用的这个,实际效果还是不错的,不过对比着下面这些新新框架,它可能稍微就臃肿麻烦一些了。 下面首先是我们鸿神的AutoLayout, 上效果: 我们看到效果还是不错的,他这个框架的使用实际上是将LinearLayout

Constraint to bottom layout guide with TabBar issue

让人想犯罪 __ 提交于 2019-12-18 19:33:51
问题 I have UITabBarController based iPad app with containerView on the first tab. The containerView has standard vertical spacing to bottom layout guide. When I tap on the second tab and then go back to the first tab, my container moves down by 56 pts, the height of the tabBar and is then covered by the tabBar. I made 3 screenshots to illustrate that. The third screenshot shows hidden tabBar after the jump between tabs. It looks like the bottom layout guide went down to the edge. What is going on

Constraint to bottom layout guide with TabBar issue

喜你入骨 提交于 2019-12-18 19:33:34
问题 I have UITabBarController based iPad app with containerView on the first tab. The containerView has standard vertical spacing to bottom layout guide. When I tap on the second tab and then go back to the first tab, my container moves down by 56 pts, the height of the tabBar and is then covered by the tabBar. I made 3 screenshots to illustrate that. The third screenshot shows hidden tabBar after the jump between tabs. It looks like the bottom layout guide went down to the edge. What is going on