nslayoutconstraint

How to add Equal Spacing and equal width for button in iOS Auto layout

不羁岁月 提交于 2019-12-27 19:14:43
问题 Am new to Auto layout constraints in Xcode. I have one Bottom View like UITabBar with 6 UIButtons . Without constraints I aligned those buttons with 5 space padding with each buttons and each buttons has 50 width. Now,I am trying to make it by using Auto layout to support all Screen sizes. In Storyboard constrains I set equal width for 6 buttons and I made 60 space between each buttons. I set first button 0 to leading space and I set the last button 0 to tail constraints. I want the buttons

How to add Equal Spacing and equal width for button in iOS Auto layout

北城余情 提交于 2019-12-27 19:14:39
问题 Am new to Auto layout constraints in Xcode. I have one Bottom View like UITabBar with 6 UIButtons . Without constraints I aligned those buttons with 5 space padding with each buttons and each buttons has 50 width. Now,I am trying to make it by using Auto layout to support all Screen sizes. In Storyboard constrains I set equal width for 6 buttons and I made 60 space between each buttons. I set first button 0 to leading space and I set the last button 0 to tail constraints. I want the buttons

Unable to simultaneously satisfy constraints while applying auto layout constraints programatically

江枫思渺然 提交于 2019-12-27 00:54:28
问题 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. ( "<NSLayoutConstraint:0x7f844b716390 H:|-(30)-[UIButton:0x7f844b4be3c0'LOGIN'] (Names: '|':UIView:0x7f844b492a80 )>", "<NSLayoutConstraint:0x7f844b706ee0 H:[UIButton:0x7f844b4be3c0'LOGIN'(100)]>", "

I have a UILabel positioned on the screen with autolayout, but when I hide the navigation bar it causes the label to “twitch” for a second [duplicate]

我是研究僧i 提交于 2019-12-25 18:24:14
问题 This question already has answers here : Using AutoLayout, how do I keep a UILabel in the same place when the navigation bar disappears? (3 answers) Closed 6 years ago . Project: http://cl.ly/1T2K0V3w1P21 It's best seen through the project, it's a small download stripped down to just the view controller. Basically, my UILabel stays in place perfectly with auto layout, but when I hide the navigation bar (you can do this in the project by tapping the screen anywhere) it causes it to twitch. How

Bottom and Right constraints of view are negative?

落爺英雄遲暮 提交于 2019-12-25 16:41:40
问题 Here is a method in which I pin a subview to a UIView instance. Excuse the messy code, I have been experimenting trying to get this to work. open static func withEmbeddedView(_ view: UIView, andFixedHeight height: CGFloat) -> PMGAlertControllerEmbedComponent { let base = PMGAlertControllerEmbedComponent(frame: CGRect.zero) base.addSubview(view) view.translatesAutoresizingMaskIntoConstraints = false base.translatesAutoresizingMaskIntoConstraints = false let left = NSLayoutConstraint(item: view

Constraints set in code doesn't reflect in the output(Autolayout iOS)

拜拜、爱过 提交于 2019-12-25 12:27:10
问题 I have 2 views that I have taken in storyboard but I haven't set any layouts in the storyboard.I want to set them by code.So here is what I did: I read about autoResizingMask property of a view and 'translatesAutoResizingMaskIntoConstraints'.So setting 'translatesAutoResizingMaskIntoConstraints' to 'NO' makes sense.So I have done that but still I' not able to set the constraints programmatically.Now,as some constraints are automatically set in storyboard when we take the views from storyboard

Swift - Constraints issue in expandable TableViewCell

梦想与她 提交于 2019-12-25 08:14:06
问题 I'm creating an expandable cell with labels and picker view xib Cell Implementation class PickerViewCell: UITableViewCell { @IBOutlet weak var detailLabel: UILabel! @IBOutlet weak var titleLabel: UILabel! @IBOutlet weak var height: NSLayoutConstraint! @IBOutlet weak var picker: UIDatePicker! var isExpanded:Bool = false { didSet { if isExpanded == false{ self.height.constant = 0.0 self.picker.hidden = true } else{ self.height.constant = 200.0 self.picker.hidden = false } } } override func

Align text fields using dynamic constraints

倾然丶 夕夏残阳落幕 提交于 2019-12-25 08:09:44
问题 I've been learning how to make iOS apps, and have come across a minor annoyance. I can't find an easy way to align my text inputs. Looking at the below screenshot, you will see that I've managed to align my text fields, which is what I want. However, I did this manually by changing the individual Leading Space between each Label and Text Field. My question is, how can I dynamically align my text fields? 回答1: Anand has posted nice way, but I personally use equal widths and heights in this kind

I add a “align” constraint, but Xcode add a “pin” constraint autolayout

 ̄綄美尐妖づ 提交于 2019-12-25 04:45:29
问题 When we add constraints, we have the choice between "Align" button in the auto layout toolbar or "Pin" button. In my storyboard, if I add a new alignment constraint "Bottom edges" between a scrollview and his container. The icon of this constraint is 2 squares and a line. But after, in the list of constraints of my scrollview, the icon is different : The icon is a "Pin" icon. I don't understand why. One more question, I think it's related : what is the difference between "Align bottom" and

Setting constraints to UIScrollView

柔情痞子 提交于 2019-12-25 02:32:13
问题 Need some help to set constraints to UIScrollView. I tried to follow the instructions here: https://developer.apple.com/library/ios/technotes/tn2154/_index.html (Mixed approach). Setting 4 sided constraints to UIScrollView. Then set 4 sided constraints to the buttonContainer. This the result: However xcode is giving this error message: If I try xcode's recommendation, either the scrollview will not scroll, or it doesn't display at all. Any idea what's wrong here? 回答1: The messages you are