nslayoutconstraint

UITableViewAutomaticDimension not working in Xcode 6.3

六眼飞鱼酱① 提交于 2019-12-03 10:23:53
I updated my Xcode to 6.3 along with Swift 1.2, and I made the transition. Everything works except dynamic row height for table view. I have those on 3 completely different table views, so it probably isn't something else influencing the bug. I set all of the table views to: tableView.rowHeight = UITableViewAutomaticDimension and all of my xib files are properly constrained. Any ideas? I simply added UITableViewAutomaticDimension to estimatedrowforindexpath as well. You can see how it works on the BEAM App (under 'people' category). - (CGFloat)tableView:(UITableView *)tableView

How to change Auto Layout constraints after they are set when using constraintEqualToAnchor()?

ε祈祈猫儿з 提交于 2019-12-03 10:07:05
I try to set up a view with AutoLayout constraints by using constraintEqualToAnchor() : override func viewDidLoad() { super.viewDidLoad() let myView = UIView() myView.backgroundColor = UIColor.orangeColor() myView.translatesAutoresizingMaskIntoConstraints = false view.addSubview(myView) myView.leftAnchor.constraintEqualToAnchor(view.leftAnchor).active = true myView.trailingAnchor.constraintEqualToAnchor(view.trailingAnchor).active = true myView.topAnchor.constraintEqualToAnchor(view.topAnchor).active = true myView.bottomAnchor.constraintEqualToAnchor(view.bottomAnchor).active = true /*********

Using Auto Layout, how do I make two labels on the same “line” be dynamic in their widths (adjusting with how wide each one needs to be)?

那年仲夏 提交于 2019-12-03 09:42:52
Say I have two UILabels, one is a URL and one is a timer: [http://website.com/link/to/specific/story] [9m 42s] But the "timer" UILabel changes width a lot. Sometimes it is just 12s for example, other times it is 125h 32m 8s . There's a lot of variability. I want the timer UILabel to take up as much width as it needs and the URL label to take up the rest . This means if the timer is longer, shorter URLs, etc. How do I do this in Auto Layout? Preferably in Interface Builder? You should set the compression resistance, URL label must have lower value; Set the horizontal space between labels to

Where is the Xcode checkbox “Translates Autoresizing Mask Into Constraints”

天涯浪子 提交于 2019-12-03 09:38:05
In one of the WWDC 2012 videos, Auto Layout By Example, they demo an OS X app using Autolayout, and at about 7 or 8 minutes in, he shows how for a single view, you can uncheck a box in the Attributes Inspector, and the box is called something like "Translates Autoresizing Mask Into Constraints" . Now, I'm well aware of the code equivalent of this box, the translatesAutoresizingMaskIntoConstraints boolean, but I can't seem to find this checkbox anywhere in either iOS or OS X projects. My project uses Autolayout. I really would like this checkbox, because one of things I'm struggling with in

Handling AutoLayout constraint animation differences in iOS 10?

谁说我不能喝 提交于 2019-12-03 09:27:33
I've noticed that in iOS 10 Beta 5 (about to try Beta 6), AutoLayout constraint animation behaves a bit differently. For example, this approach does not work the same as it did in previous iOS releases: [view addConstraints:@[constraints...]]; [view setNeedsUpdateConstraints]; [view layoutIfNeeded]; [UIView animateWithDuration:... { /* adjust constraint here... */ [view layoutIfNeeded]; // Only the adjusted constraints since previous layoutIfNeeded() call should animate change with duration. } completion:{ ... }]; ... In my testing, the constraints initially added with addConstraints() will

Enable + Disable Auto-Layout Constraints

寵の児 提交于 2019-12-03 09:04:57
问题 I have a simple (I think) problem: I have a UIImageView , which I have set multiple constraints for in the storyboard. At times, I'll need to disable the constraints, and set its frame manually, but later, I'll want to re-enable those constraints and have the view return to where it was as decided by the constraints. I thought I could do this with something like: @IBOutlet weak var imageView: UIImageView! @IBOutlet weak var constraint: NSLayoutConstraint! func example() { //to set its

NSLayoutConstraint in swift

匿名 (未验证) 提交于 2019-12-03 08:33:39
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am trying to convert the following code to Swift: leftConstraint = [NSLayoutConstraint constraintWithItem:self.contentView attribute:NSLayoutAttributeLeft relatedBy:0 toItem:self.view attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0]; [self.view addConstraint:leftConstraint]; Can someone give me the new syntax to do it in Swift? Thanks a lot The correct syntax is : let leftConstraint = NSLayoutConstraint(item:self.maView, attribute:NSLayoutAttribute.Left, relatedBy:NSLayoutRelation.Equal, toItem:self.view, attribute

Building a titleView programmatically with constraints (or generally constructing a view with constraints)

感情迁移 提交于 2019-12-03 08:16:47
问题 I'm trying to build a titleView with constraints that looks like this: I know how I would do this with frames. I would calculate the width of the text, the width of the image, create a view with that width/height to contain both, then add both as subviews at the proper locations with frames. I'm trying to understand how one might do this with constraints. My thought was that intrinsic content size would help me out here, but I'm flailing around wildly trying to get this to work. UILabel

how can i increase the height of an inputAccessoryView

白昼怎懂夜的黑 提交于 2019-12-03 07:24:19
问题 I have spent several days on this with no solution in sight. I have an inputAccessoryView which consists of a UIView containing a textView and two buttons. The behaviour of the inputAccessoryView is as expected and works fine in all cases except one. When the height of the textView increases, I am trying to increase the height of the inputAccessoryView by the same amount. When I redefine the height of the inputAccessoryView in textViewDidChange , the inputAccessoryView increases height

Centering view with visual format NSLayoutConstraints

老子叫甜甜 提交于 2019-12-03 06:30:42
问题 I am trying to center a view using the visual format language. [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-[_progressView(300)]-|" options:NSLayoutFormatAlignAllCenterY metrics:0 views:views]]; ( views is a NSDictionaryOfVariableBindings containing _progressView ) It does not center my view (width: 300) within the self.view (width: 768). It aligns it left with an 8 pixel margin, as if I would have only written @"H:|-[_progressView(300)" . Is the only way to