nslayoutconstraint

Unable to make outlet connection to a constraint in IB

不打扰是莪最后的温柔 提交于 2019-11-26 18:55:29
I am running XCode 5 with iOS 7. I need to dynamically change the height constraint of a UITextView prior to its layout. I have seen many postings stating that this can be done by making an outlet connection from the constraint in IB to the source code. I am trying to make the connection from the constraint outlet in IB to the header file of the owning class, but am unable to make the connection - IB does not "highlight" when I drag over the header file, as it does when making connections from other objects like buttons etc. Has anyone encountered this before? All help is greatly appreciated.

Setting constraints programmatically

*爱你&永不变心* 提交于 2019-11-26 18:03:52
问题 I'm experimenting with how to use UIScrollView. After much trouble, I finally got the hang of it. But now I've seem to hit another snag. In this simple app, I have a scroll view with and in order for it to work, I have to set the view's bottom space to scrollview constraint to 0 as described here and it works fine. I'm doing it through the IB. Now I've come across a scenario where I have to do that part programmatically. I've added the below code in the viewDidLoad method. NSLayoutConstraint

When can I activate/deactivate layout constraints?

不打扰是莪最后的温柔 提交于 2019-11-26 15:36:57
问题 I've set up multiple sets of constraints in IB, and I'd like to programmatically toggle between them depending on some state. There's a constraintsA outlet collection all of which are marked as installed from IB, and a constraintsB outlet collection all of which are uninstalled in IB. I can programmatically toggle between the two sets like so: NSLayoutConstraint.deactivateConstraints(constraintsA) NSLayoutConstraint.activateConstraints(constraintsB) But... I can't figure out when to do that.

Auto layout constraints issue on iOS7 in UITableViewCell

只愿长相守 提交于 2019-11-26 14:55:29
I'm using auto layout constraints programmatically to layout my custom UITableView cells and I'm correctly defining the cell sizes in tableView:heightForRowAtIndexPath: It's working just fine on iOS6 and it does look fine in iOS7 as well BUT when I run the app on iOS7, here's the kind of message I see in the console: Break on objc_exception_throw to catch this in the debugger. The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful. 2013-10-02 09:56:44.847 Vente-Exclusive[76306:a0b] Unable to simultaneously satisfy constraints.

Using autolayout in a tableHeaderView

倾然丶 夕夏残阳落幕 提交于 2019-11-26 13:08:40
问题 I have a UIView subclass that contains a multi-line UILabel . This view uses autolayout. I would like to set this view as the tableHeaderView of a UITableView ( not a section header). The height of this header will depend on the text of the label, which in turn depends on the width of the device. The sort of scenario autolayout should be great at. I have found and attempted many many solutions to get this working, but to no avail. Some of the things I\'ve tried: setting a

Programmatically Add CenterX/CenterY Constraints

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-26 12:54:19
问题 I have a UITableViewController that doesn\'t display any sections if there is nothing to show. I\'ve added a label to indicate to the user that there is nothing to display with this code: label = UILabel(frame: CGRectMake(20, 20, 250, 100)) label.text = \"Nothing to show\" self.tableView.addSubview(label) But now, I want it to be centered Horizontally and Vertically. Normally, I would choose the two options highlighted (plus ones for height and width) in the screenshot: I\'ve tried the

Can I change multiplier property for NSLayoutConstraint?

我与影子孤独终老i 提交于 2019-11-26 12:12:19
I created two views in one superview, and then added constraints between views: _indicatorConstrainWidth = [NSLayoutConstraint constraintWithItem:self.view1 attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:self.view2 attribute:NSLayoutAttributeWidth multiplier:1.0f constant:0.0f]; [_indicatorConstrainWidth setPriority:UILayoutPriorityDefaultLow]; _indicatorConstrainHeight = [NSLayoutConstraint constraintWithItem:self.view1 attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:self.view2 attribute:NSLayoutAttributeHeight multiplier:1.0f constant:0.0f];

With Auto Layout, how do I make a UIImageView&#39;s size dynamic depending on the image?

六月ゝ 毕业季﹏ 提交于 2019-11-26 11:59:21
问题 I want my UIImageView to grow or shrink depending on the size of what the actual image it\'s displaying is. But I want it to stay vertically centered and 10pts from the leading edge of the superview. However, if I set these two constraints it complains I haven\'t set up enough constraints to satisfy Auto Layout. To me it seems to perfectly describe what I want. What am I missing? 回答1: The image view's intrinsic size is already dependent on the size of the image. Your assumptions (and

Moving views with constraints

好久不见. 提交于 2019-11-26 11:33:53
问题 I have a couple views in my view controller that move up when an up swipe is detected then down when a down swipe is detected. I was forcing the views to move by adjusting the y origin using CGRectOffset. I\'ve now applied constraints to my views with IB and I\'m not sure whats the best way to move the views so that they end up in the right position on the iphone 5, 6, and 6+. Currently I\'m doing something like this: [self.view layoutIfNeeded]; self.panFrameVerticalConstraint.constant = self

Hide autolayout UIView : How to get existing NSLayoutConstraint to update this one

◇◆丶佛笑我妖孽 提交于 2019-11-26 11:27:42
问题 I know how to modify a existing constraint. But I would to know if someone has found a solution to get a constraint without save this one as a property. Current solution to set Constraint height: 1) save NSLayoutConstraint in a variable: NSLayoutConstraint *heightConstraint = [NSLayoutConstraint constraintWithItem:myView attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0f constant:20]; [self.view addConstraint