View Controllers, Views and Storyboards
View Controllers, Views and Storyboards
- Subject: View Controllers, Views and Storyboards
- From: Dave <email@hidden>
- Date: Mon, 22 May 2017 16:27:14 +0200
Hi All,
I have a question about View Controllers in Storyboard’s.
In the past I have handled Landscape and Portrait Views as two separate Hierarchies in XCode/IB. I defined the roots Views inside the View Controller but NOT in the main .view. I then hooked these up to the View Controller Class as IBOutlets and then adding one or the to the main view in viewWillAppear. E.g.
In IB:
Main “view” - empty.
LandscapeRootView - Hierarchy of Views.
PortraitRootView - Hierarchy of Views.
In the View Controller Class:
@property (nonnull,strong) IBOutlet UIStackView* pPortraitRootStackView;
@property (nonnull,strong) IBOutlet UIStackView* pLandscapeRootStackView;
Then in viewWillAppear:
[self.view removeAllSubviews];
if (Orientation == Portrait)
[self.view addSubview:self. pPortraitRootStackView];
else
[self.view addSubview:self. pLandscapeRootStackView];
However when I come to do this in a Storyboard, I can create the Views OK, but it XCode/IB won’t let me hook it up to the Outlets.
I’m using Auto-layout and can’t find a way to make it work with just one view hierarchy as the constraints clash.
Any ideas on how to achieve this would be greatly appreciated.
All the Best
Dave
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden