ViewDeck (https://github.com/Inferis/ViewDeck) is an amazing library that helps you to easily add a Facebook like menu into your application, unfortunelly it has a small issue with storyboards causing to not load the IIViewDeckController code properly.
In order to make use of ViewDeck in a specific scene of my storyboard, I created a blank scene with a empty view, in viewDidLoad method I added the following lines of code:
1 2 3 4 5 6 7 8 9 10 | UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil]; CenterViewController *centerController = (CenterViewController *)[storyboard instantiateViewControllerWithIdentifier:@"CenterViewController"]; RightViewController *rightController = (RightViewController *)[storyboard instantiateViewControllerWithIdentifier:@"RightViewController"]; self.containerController = [[IIViewDeckController alloc] initWithCenterViewController:centerController leftViewController:rightController rightViewController:rightController]; self.containerController.view.frame = self.view.bounds; [self.view addSubview:self.containerController.view]; |
But this isn’t enough to get ViewDeck working, since I’m adding IIViewDeckController as child view of scene controller view, the viewWillAppear of IIViewDeckController doesn’t get called, which causes to not load ViewDeck on screen as it should be, hopefully you can fix it by calling viewWillAppear manually when viewWillAppear of scene controller is fired, like below:
1 2 3 4 5 6 | - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; [self.containerController viewWillAppear:YES]; } |
After this small change you will be ready to use ViewDeck in you storyboard based projects!
Could you serve little demo somewhere?
Done it by my self:
http://dl.dropbox.com/u/107952/inferisStoryboardExample.zip
This is a terrible idea…
Try this instead:
-(id)initWithCoder:(NSCoder *)aDecoder{
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
menuController = (MenuViewController*)[storyboard instantiateViewControllerWithIdentifier:@"MenuViewController"];
mainController = (MainViewController*)[storyboard instantiateViewControllerWithIdentifier:@"MainViewController"];
friendsController = (FriendsViewController*)[storyboard instantiateViewControllerWithIdentifier:@"FriendsViewController"];
self = [super initWithCenterViewController:mainController leftViewController:menuController rightViewController:friendsController];
if (self) {
NSLog(@”self initWithCoder”);
}
return self;
}
You should never add a viewcontroller’s view to another viewcontroller. That may work now in iOS5 but it didn’t work in iOS4 and shouldn’t work 100% of the time.
@brandon,
Where do you add the initWithCoder method?
Hello,
Where do you add the initWithCoder code?
Thanks in advance.
Good question.
Where to put the initWithCoder code?
In center or right controller.