Previously rendered IBDesignable hangs on "Updating" in storyboard
Asked Answered
P

1

12
  • Xcode 7.0.1 (7A1001)
  • iOS 9.0

I made a custom @IBDesignable UIView, only implementing the drawRect function. Like so:

@IBDesignable
class CustomView: UIView {
    override func drawRect(rect: CGRect) {
        let context = UIGraphicsGetCurrentContext()
        // Lots more drawing code after this
        // ...
    }
}

While I was writing this drawRect, I had a storyboard with several different instances of this rendering on a view controller. When I made a change in drawRect and saved, these changes would be reflected in the storyboard in close to real time. There was even an IBInspectable String which allowed me to change an enum type and draw differently depending on that. The views could be resized in the storyboard, and the new width and height would be accounted for in my drawing code, and the drawing would be scaled and translated, exactly as I intended.

This was all working fine, and I had not made any changes to that UIView subclass, but I did delete my test views in the storyboard while building out newer views which would actually end up using this custom view.

After doing a lot of dancing around with constraints, I was ready to place my custom view where it belonged. But it does not work. While the identity inspector acknowledges my custom class as an IBDesignable, it hangs on "Updating" status.

identity inspector of custom uiview ibdesignable

To prove I wasn't going crazy, I made entirely new @IBDesignable UIView subclasses which implemented simple drawRects or even completely empty drawRects. These are now having the same issue and are not rendering on the storyboard.

Note that I can run this in the simulator and the drawing appears as I expect at runtime. So what happened to the storyboard's ability to give that nice feedback I expect from an IBDesignable?

Things I have tried:

  • Clean / clean build folder / clearing XCode Derived Data directory
  • Restarting XCode
  • Deleting / commenting out drawRect guts
  • Making the most simple @IBDesignables with HelloWorld-like tutorials
  • Using existing known working @IBDesignables
  • Creating fresh UIViewController in storyboard to place custom view
  • Toggled: Editor > Automatically Refresh Views
  • Editor > Refresh All Views
  • Editor > Debug Selected Views

All these attempts continue to show "Updating" in Custom Class section of the identity inspector.

Clearly something beyond my implementation is causing a problem here. Anybody else having this issue? Can anybody point me in the right direction? Not sure what else to try.

Perichondrium answered 9/10, 2015 at 18:33 Comment(2)
just a blind guess, try to override prepareForInterfaceBuilder() and invoke inside 'setNeedsDisplay'. Do you need to use so old Xcode? My guess is that probably it's a bug in this version of Xcode. Anyway in each version @IBDesignable often fail to render ;) especially when you edit them. Often I need to clean everything and restart Xcode.Water
Did you manage to find a solution to this?Saint
A
-1

In the Identity inspector where it says "Module" add your AppName

enter image description here

Adversity answered 31/7, 2019 at 1:56 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.