nslayoutconstraint

Adding constraints in SDCAlertView

浪尽此生 提交于 2019-12-12 21:06:17
问题 I'm using a the pod SDCAlertView, I need to add an imageView + a textField to my content view, however I am having trouble with my constraints, below is my code. let imageView = UIImageView(frame: CGRectMake(0, 0, 100, 100)) imageView.image = UIImage(named: "kalafina") imageView.contentMode = .ScaleAspectFill let alert = AlertController(title: "Testing", message: "1234") imageView.translatesAutoresizingMaskIntoConstraints = false alert.contentView.addSubview(imageView) let

iOS: addConstraints: crashing app

烈酒焚心 提交于 2019-12-12 13:37:49
问题 Problem I can't seem to adopt Auto Layout into my existing project. Details I was having the same issue before as this question presentViewController: crash on iOS <6 (AutoLayout) but none of the provided answers were a solution for me: I'm using all storyboard views with no xibs. My 'Use Auto Layout' setting is already turned off and I am using nothing but iOS 6. My view controller was initially crashing, so I set the constraints to be added with a delay and now my app crashes during any

Unexpected NSAutoresizingMaskLayoutConstraint adding UIView from nib to autolayout storyboard scene

↘锁芯ラ 提交于 2019-12-12 08:25:33
问题 I've got the following in IB and both views have 'Use Auto Layout' on and 'Resizes Subviews' off. I'm simply trying to add an instance of Autolayout View to a container view so its edges meet its container view's edges. The container view has Uses Auto Layout on and is the same height but width is twice as much. Here's the code: - (IBAction)addSubviewButton:(id)sender { UIView *autolayoutView = [[[NSBundle mainBundle] loadNibNamed:@"AutolayoutView" owner:nil options:nil] objectAtIndex:0];

Can't programmatically set NSLayoutConstraint multiplier in swift… "Cannot assign to the result of this expression

*爱你&永不变心* 提交于 2019-12-12 08:06:52
问题 I am trying to programmatically set the constraint for a multiplier in swift, and when I set the value, it just gives me the error, "Cannot assign to the result of this expression"... I declared the NSLayoutConstraint with an IBOutlet, and then set the multiplier, same as I did with the constant for another, which works fine, but this one won't accept it... @IBOutlet weak var clockWidthConstraint: NSLayoutConstraint! override func updateViewConstraints() { super.updateViewConstraints()

Content hugging priority Dynamic Cell Size

最后都变了- 提交于 2019-12-12 06:16:11
问题 Recently I've had a complex auto layout situation that has been solved (thanks to @Catalina T.). Currently I'm experiencing an issue with Content Hugging Priority. I have 4 dynamic labels that may contain huge texts so cells should fit the content. With the current constraints and priorities if I set huge texts to all dynamic labels it works perfectly (though one of them won't be displayed fully instead it will be clipped with dots). If I set the third label's text to a huge one auto layout

Aspect ratio constraint relative to the screen width

随声附和 提交于 2019-12-12 05:18:05
问题 I have set a cell image to my UITableViewCell . It is a custom cell. I have set the aspect ratio as 1:1 and the width of the image view to 50. But for iphone 5 and 5s this size is too big as I feel. So how can I change the size of the UIImageView relative to the screen width. Please help me. Thanks This is my current view 回答1: There are at least 2 ways you could configure image size based on the screen size: Size-Classes allows you to set different width constraint value based on Trait

Two non-conflicting constraints creating a NSLayoutConstraint error

给你一囗甜甜゛ 提交于 2019-12-12 04:48:57
问题 I have two constraints on a UILabel pinning the lead and the tail to the superview. The problem is, when I open the view in the app, I get this error: 2015-04-11 22:00:24.319 TradingPost[7610:60b] 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.

Swift 3 - Custom TableViewCell dynamic height - programatically

*爱你&永不变心* 提交于 2019-12-12 04:42:21
问题 I am trying to setup dynamic height for my custom table view cell...programatically. There are many tutorials for doing it inside the storyboard, but this is about a pure programmatic solution: class CustomTableViewCell: UITableViewCell { var container: UIView = { let view = UIView() view.translatesAutoresizingMaskIntoConstraints = false return view }() override func awakeFromNib() { super.awakeFromNib() self.setupView() self.addConstraints() } func setupView() { self.contentView.addSubview

How to add a custom UIView programmatically with Swift and see it in Interface Builder

与世无争的帅哥 提交于 2019-12-12 04:16:15
问题 I'm trying to add a UserView with controller to a view with Xcode 7 / Swift 2.0. I was not able to figure out how to do this using Interface Builder, instead I added a NSView as a placeholder view and then add the view in code. Is it possible to do it with the Interface Builder? In the image, the orange is the place holder and the green is the user view: When adding the view in code, I assume I have to add the constraints. I tried to use the constraintsWithVisualFormat like below, but when I

UIScrollView and constraints issue

微笑、不失礼 提交于 2019-12-12 03:49:12
问题 I create a UIScrollView: // datasetSubView.m UIScrollView *scrollView = [UIScrollView new]; scrollView.translatesAutoresizingMaskIntoConstraints = FALSE; scrollView.userInteractionEnabled = TRUE; scrollView.scrollEnabled = TRUE; scrollView.backgroundColor = [UIColor whiteColor]; scrollView.alpha = 0; self.filterListView = scrollView; Then in my UIViewController, I add the scroll view and give it a size: [self.view addSubview:self.datasetSubBar.filterListView]; [self.view addConstraints: