Storyboard Won't Update in Simulator

Storyboard changes not updating in simulator/iphone

Xcode 5 changed the control over constraints. This will often lead to mistakes in the beginning. Use the Resolve Auto Layout Issues button to fix your mistakes.

Xcode 5 Resolve Autolayout Issues

Go to storyboard and look for the menu bar to find the Resolve Auto Layout Issues button.
There you can update constraints, add missing constraints, reset to suggested constraints, or clear all constraints.

Xcode storyboard changes not showing on device or simulator

This solution had worked for me:

Just delete that storyboard in which changes are not reflecting and take new storyboard instead it will start reflecting changes.

IBInspectable not updating in storyboard but works on simulator

Firstly, you need @IBDesignable directive to render the updates in Storyboard whereas @IBInspectable is only to access the property directly in the Storyboard.

Secondly, you have extended the UIView class to show the inspectable properties in the Storyboard but without @IBDesignable.

Now you would think adding @IBDesignable would solve your problem but sadly you can't apply @IBDesignable on an extension like so:

@IBDesignable //won't work on an extension
extension UIView {
//...
}

You can only apply the @IBDesignable directive on a class you have access to, like so:

@IBDesignable
class MyPrettyDesignableView: UIView {
//...
}


Solution:

Bottomline is that you should subclass UIView and apply the @IBDesignable directive on this class.

Basically, your only option is:

@IBDesignable
class MyPrettyDesignableView: UIView {

@IBInspectable var cornerRadius: CGFloat = 0 {
didSet {
self.layer.cornerRadius = cornerRadius
self.layer.masksToBounds = true
}
}

@IBInspectable var borderWidth: CGFloat = 0 {
didSet {
self.layer.borderWidth = borderWidth
}
}

@IBInspectable var borderColor: UIColor = #colorLiteral(red: 0, green: 0, blue: 0, alpha: 1) {
didSet {
self.layer.borderColor = borderColor.cgColor
}
}

}

Then in the storyboard, go to the view that you want designable in storyboard and change it's custom class to MyPrettyDesignableView.

  1. Change it's custom class to your IBDesignable subclass:
    IBDesignable

  2. Set the IBInspectable properties:
    IBInspectable

App looks different in Main.storyboard than in simulator

You need to set Constraints.

The easiest way to do it is clicking the triangle and then "Add Missing Constraints" or "Reset to Suggested Constraints" (All Views in XYZ)

Example

It takes a bunch of time to really understand how constraints and auto layout is working. And Xcode helped me a lot with the suggested constraints...

Here is a good tutorial for the start:

http://www.raywenderlich.com/115440/auto-layout-tutorial-in-ios-9-part-1-getting-started-2



Related Topics



Leave a reply



Submit