I'm coming from the world of C# and Winforms where I can build a custom UserControl and drag it onto a form as if it were a common control. Is there a way to do that in Xcode and Interface Builder?
I've only seen how to set the view at runtime but I'd like to see it on my window at design time. For example, I'd expect my custom view to be listed in the available controls.
Thanks!
Simon
Interface Builder doesn't add (or allow the addition of, now that IB Plugins are derelict) Custom Objects to the Object Library. You can only drag in existing/preset objects, but you can have IB instantiate them as instances of a subclass as long as they are instantiated the same way.
E.g. Drag in a custom view and set the class to MyCustomViewClass
, or drag in a scroll view and set the class to MyCustomScrollView
, or drag in an object and set the class to CustomObject
, et cetera.
And that is the preferred way of using custom controls in Interface Builder.
Basically just ripping off rdelmar's comment... but I thought a picture would be helpful
Drag a normal view into IB, then select it and do this.
Every Window you create in IB has a view on it as its first subcomponent. You dont need to create a separate custom view for it. If you really are subclassing it just change the class name in the inspector.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With