Closed bagusflyer closed 12 years ago
I'm not a huge fan of storyboards, so don't have good skills with it, but as far as I know you can't. The only way I see is to init the controller with storyboard, then popAndPush a new center controller by code. This will place a rootviewcontroller.
Hello, here is how we overcame this storyboard limitation in our project (storyboard sucks by the way, really.):
Let's say you have the following view hierarchy in your storyboard before PPReveal integration: TabBar > NavController > HelloWorldViewController and you want to integrate the PPReveal in the HelloWorldViewController.
It now looks like this: TabBar > NavController > PPRevealContainer,
and then you have your HelloWorldViewController lying somewhere not connected to anything (since you can't connect a regular view controller to another and you can't create custom view controllers "containers" in storyboard - once again, suck big time)
- (id)initWithCoder:(NSCoder *)aDecoder
{
self = [super initWithCoder:aDecoder];
if(self){
// Custom initialization
// init your HelloWorldViewController by its Storyboard ID (to be set in the identity inspector of HelloWorldViewController)
HelloWorldViewController* helloVC = [[UIStoryboard storyboardWithName:@"MainStoryboard_iPhone" bundle:NULL] instantiateViewControllerWithIdentifier:@"helloworld"];
// Prepare the root view controller of the PPReveal, here a Navigation Controller as recommended in PPReveal examples
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:helloVC];
// Call the legacy PPReveal initialiser method, so it can deal with all its stuffs
self = [self initWithRootViewController:nav];
// Only if you want the PPRevealContainer to be the delegate of PPReveal events, otherwise you can also set it on your HelloWorldViewController if you prefer.
self.delegate = self;
}
return self;
}
and it should work.
Here is the final picture of your view hierarchy - the part between () won't be interconnected in storyboard, since you couldn't connect the PPRevealSBContainer to anything: TabBar > NavController > PPRevealSBContainer (> NavController > HelloWorldViewController)
in otherwords, storyboard handles all the hierarchy until the PPRevealSBContainer, then its your subclass PPRevealContainer which does the rest of the work to display your HelloWorldViewController
Hope this helped! Good luck
Thanks xaxa06, hope it will be helpful for the guys who works with storyboard. And you're right, storyboard does suck ;)
Thanks xaxa06, this works fine, but has another bug for this, I found hidesBottomBarWhenPushed will not work.
Hi ,xaxa06 !!!,
Can you please send me the sample code which you integrated pprevealsideview controller with storyboard. Please its very urgent for me..
This component looks great. But there is only one issue for me to add it to my ios 5 project. My question is:
How to initialize PPRevealSideViewController in a storyboard? (Which will be root viewcontroller)
Any suggestion? Thanks