nslayoutconstraint

How to implement multiple PanGestures (Draggable views)?

北城余情 提交于 2019-12-02 08:44:24
I want to have several objects that I can drag and drop. Here's my code for moving one object (with lot of help from @vacawama): import UIKit class ViewController: UIViewController { @IBOutlet weak var panView: UIView! @IBOutlet weak var panViewCenterX: NSLayoutConstraint! @IBOutlet weak var panViewCenterY: NSLayoutConstraint! let panRec = UIPanGestureRecognizer() override func viewDidLoad() { super.viewDidLoad() panRec.addTarget(self, action: "draggedView:") panView.addGestureRecognizer(panRec) // Do any additional setup after loading the view, typically from a nib. } func draggedView(sender

I want two buttons to have equal width and position themselves proportionally in all screens sizes from the top of the scree using autolayout?

偶尔善良 提交于 2019-12-02 08:22:44
问题 Attaching the view i am planning to design. I would like to position the Buttons with respect to Superview and their Width and Height must increase proportionally to the Screen Size rather than remaining fixed. Attaching the screen preview: 回答1: This is an example just for one row of your buttons, so they can be reused for other UI elements. Put these constraints onto your buttons: LEFT BUTTON: left leading constraint top leading constraint height constraint RIGHT BUTTON right trailing

I want two buttons to have equal width and position themselves proportionally in all screens sizes from the top of the scree using autolayout?

坚强是说给别人听的谎言 提交于 2019-12-02 07:03:50
Attaching the view i am planning to design. I would like to position the Buttons with respect to Superview and their Width and Height must increase proportionally to the Screen Size rather than remaining fixed. Attaching the screen preview: This is an example just for one row of your buttons, so they can be reused for other UI elements. Put these constraints onto your buttons: LEFT BUTTON: left leading constraint top leading constraint height constraint RIGHT BUTTON right trailing constraint top leading constraint height constraint And constraints related to both buttons: (you need to select

Ambiguous layout with dynamic tableView height

ぃ、小莉子 提交于 2019-12-02 07:03:43
问题 I have a viewController and I want to have two 1 tableView and 1 childViewController inside it. tableView is non-scrollable with dynamic cell heights. (I'm using a tableView so I can collapse rows) childVC is a scrollable tableView with dynamic cell heights. my constraints are as: NSLayoutConstraint.activate([ tableView.topAnchor.constraint(equalTo: view.topAnchor), tableView.trailingAnchor.constraint(equalTo: view.trailingAnchor), tableView.leadingAnchor.constraint(equalTo: view

iOS - Placing two label together in centre of their super view

☆樱花仙子☆ 提交于 2019-12-02 06:04:35
问题 I have two label, L1 and L2 of variable and nonidentical length. I want to place these two label using constraints in Xcode. If possible i don't want to manipulate constraints programmatically. guidance will be appreciated. Right image should be the expected output Requirements, Two labels are non identical in width When running leading space of L1 and trailing space of L2 will be equal distance between L1 & L2, horizontal space is fixed, 10 px UIStackView cannot be used How can I do it from

iOS - Placing two label together in centre of their super view

杀马特。学长 韩版系。学妹 提交于 2019-12-02 00:50:02
I have two label, L1 and L2 of variable and nonidentical length. I want to place these two label using constraints in Xcode. If possible i don't want to manipulate constraints programmatically. guidance will be appreciated. Right image should be the expected output Requirements, Two labels are non identical in width When running leading space of L1 and trailing space of L2 will be equal distance between L1 & L2, horizontal space is fixed, 10 px UIStackView cannot be used How can I do it from Xcode? What you can do is put both the UILabel inside a UIView and then: Add a leading, top and bottom

Ambiguous layout with dynamic tableView height

為{幸葍}努か 提交于 2019-12-02 00:48:59
I have a viewController and I want to have two 1 tableView and 1 childViewController inside it. tableView is non-scrollable with dynamic cell heights. (I'm using a tableView so I can collapse rows) childVC is a scrollable tableView with dynamic cell heights. my constraints are as: NSLayoutConstraint.activate([ tableView.topAnchor.constraint(equalTo: view.topAnchor), tableView.trailingAnchor.constraint(equalTo: view.trailingAnchor), tableView.leadingAnchor.constraint(equalTo: view.leadingAnchor), tableView.bottomAnchor.constraint(equalTo: artistVC.view.topAnchor), ]) NSLayoutConstraint.activate

Prevent Interface Builder from auto creating Constraints?

我们两清 提交于 2019-12-01 16:21:11
I created a demo project here . I have a view where I created a ScrollView in a .xib file. In interface builder I did not set any constraints. In my viewDidLoad method I set constraints with SnapKit : scrollView.snp_makeConstraints { (make) -> Void in make.edges.equalTo(self.view) } When I run the code I get the following console output: 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

Some sort of “global” for IBDesignables?

烈酒焚心 提交于 2019-12-01 01:41:44
问题 In storyboard have a UIView, with a constraint for example "0.1" proportional height. Imagine you have a similar constraint "0.1", on views in many different scenes. Say you want to change the value 0.1 to 0.975. You have to change it individually everywhere. Is there some way to make a sort of "global value" , using @IBInspectable and/or constraints? So that you can change them all at once , and see the results all at once in storyboard . (Of course, at run-time you could propagate these in

UIStoryboard how to replace constraints programmatically?

北慕城南 提交于 2019-11-30 21:27:50
I have a view controller laid out in a storyboard with autolayout enabled and am looking for a way to change constraints to allow for my view to rotate into landscape and rearrange buttons on the screen. When I try the code below, I get about two dozen "unable to satisfy constraints, breaking constraint..." messages that I cannot really decode. Is there a way to dynamically replace constraints from a storyboard with constraints that I specify programmatically? I want to completely override the layout of the buttons that I defined in a storyboard. -(void)updateViewConstraints { [super