Swift – IBOutletCollection equivalent

Update: This works properly in Xcode now – “Outlet Collection” is one of the connection options in Interface Builder, which creates something that looks like: @IBOutlet var labelCollection: [UILabel]! While we’re waiting for a fix, you can approximate this using a computed property. Let’s say my view has five UILabels that I want in a … Read more

Xcode 9 – “Fixed Width Constraints May Cause Clipping” and Other Localization Warnings

I was getting the same warnings even without multiple languages in my app, which led me to find out what was really going on. . . There are a few different things going on here. I was able to silence the fixed-width warnings in my own app by changing the width of the object spacings … Read more

Can I disable autolayout for a specific subview at runtime?

I had the same problem. But I have resolved it. Yes, you can disable auto layout at runtime for a specific UIView, instead of disabling it for the whole xib or storyboard which is set by default in Xcode 4.3 and later. Set translatesAutoresizingMaskIntoConstraints to YES, before you set the frame of your subview: self.exampleView.translatesAutoresizingMaskIntoConstraints … Read more

Can I use setFrame and autolayout on the same view?

Yes, this can be done. If you set a view’s translatesAutoresizingMaskIntoConstraints = YES, then calls to setFrame: are automatically translated at runtime into layout constraints based on the view’s current autoresizingMask. This lets you mix frame-based layout with constraint-based layout. For instance you could use Auto Layout to define the layout of all of the … Read more

Is it possible to set UIView border properties from interface builder?

Actually you can set some properties of a view’s layer through interface builder. I know that I can set a layer’s borderWidth and cornerRadius through xcode. borderColor doesn’t work, probably because the layer wants a CGColor instead of a UIColor. You might have to use Strings instead of numbers, but it works! layer.cornerRadius layer.borderWidth layer.borderColor … Read more

How to use Auto Layout to move other views when a view is hidden?

It is possible, but you’ll have to do a little extra work. There are a couple conceptual things to get out of the way first: Hidden views, even though they don’t draw, still participate in Auto Layout and usually retain their frames, leaving other related views in their places. When removing a view from its … Read more

UISplitViewController in portrait on iPhone shows detail VC instead of master

Oh man, this was causing me a headache for a few days and could not figure out how to do this. The worst part was that creating a new Xcode iOS project with the master-detail template worked just fine. Fortunately, in the end, that little fact was how I found the solution. There are some … Read more