Add subView in storyboard
Solution 1
You don't actually need to write any code for this. There are many ways to do this:
Select the subview and drag over the view entry in the Objects Explorer of storyboard. Once you leave the mouse hold, the parent view will have a triangle indicating your subview has become its child and the subview will have a bigger indent than your view
Or you can use the "Embed in View" menu as shown in the below pic [source:http://codesheriff.blogspot.co.il/2014/03/8-tips-for-working-effectively-with.html]
Solution 2
open file inspector ->search for view drag and Drop the view in storyboard
so in this you already holding a view now you adding an view its almost like adding a sub view to the main view this is for adding view without code
user3424037
Updated on June 27, 2022Comments
-
user3424037 almost 2 years
In my program needs to create view, then create subView and add it in view. I create view and subView in storyboard. Then in code:
[subView removeFromSuperview]; [view addSubview:subView]; [self.view addSubview:view];
How can I add subView to view in storyboard without code?
-
user3424037 over 10 yearsDrag n drop add subView in self.view but I want in view.
-
Tarek Hallak over 10 yearsDrag and drop it on the view, or drop it in the left inspector.
-
user3424037 over 10 yearsHow open left inspector?)
-
Tarek Hallak over 10 yearsctr+cmd+right arrow, ctrl+cmd+left arrow
-
-
user3424037 over 10 yearsview and subView added in self.view. I remove subView from self.view, add it in view and then add view in self.view.
-
Mikerizzo over 10 yearstry this: [subView removeFromSuperview]; UIView *aView = [[UIView alloc] init]; [aView addSubview:subView]; [self.view addSubview:aView];
-
user3424037 over 10 yearsare you kidding me? I want that I can do it. In first post write "without code"
-
Christophe Weis over 8 yearsCould you elaborate? This does not seem to be very clear and precise.
-
RAGHUNATH over 8 years@Christophe Weis. If we go through the Storyboard,It won't provide design exactly how we want.so only we are writing code dynamically.This is shown clearly in this link raywenderlich.com/50317/… Pls Upvote if it is useful to you..
-
RAGHUNATH over 8 yearsWhy you gave negative.