I’m building a UI in XCode interface builder. After having layed out the required view hierarchy, I realised that one of the views closer to the top of the hierarchy should be a UIScrollView and not a UIView.
Is there any way to easily change that view’s type from UIView to UIScrollView without having to re-layout all the child components with their own sub-view hierarchies?
Yes, click on the
UIViewthat you want to change. After selecting it, open the Identity Inspector pane.From the Identity Inspector, you should see a field at the top named ‘Class’, and the current value, in grey, should say ‘UIView’.
Enter ‘UIScrollView’ and hit Enter.
This will update your Nib file and my your former
UIViewto aUIScrollView. Also, if you have already wired the view to anIBOutlet, make sure you update theIBOutletclass definition, if it is not anid.