I am trying to implement the JASidePanels example2 using storyboard. https://github.com/gotosleep/JASidePanels#example-2-storyboards
-(void)awakeFromNib
{
[self setLeftPanel:[self.storyboard instantiateViewControllerWithIdentifier:@"leftViewController"]];
[self setCenterPanel:[self.storyboard instantiateViewControllerWithIdentifier:@"centerViewController"]];
[self setLeftPanel:[self.storyboard instantiateViewControllerWithIdentifier:@"rightViewController"]];
}
If I added above code into CenterViewController.m that was as same as MySidePanelController.m in the example2, the app was crashed like below.
-(void)awakeFromNib
{
// [self setLeftPanel:[self.storyboard instantiateViewControllerWithIdentifier:@"leftViewController"]];
// [self setCenterPanel:[self.storyboard instantiateViewControllerWithIdentifier:@"centerViewController"]];
// [self setLeftPanel:[self.storyboard instantiateViewControllerWithIdentifier:@"rightViewController"]];
}
If I commented out like above, the app worked like below.
I'm new to iOS. Could you tell me what is wrong?
My environment.
You are causing a stackoverflow by calling the code in -awakeFromNib
in your center view controller as it sets another center view controller as its center panel and goes this way till the app crashes.
You need to have a subclass of JASidePanelController
where you implement the-awakeFromNib
and your other 3 view controllers that you set as panels.
#import "JASidePanelController.h"
@interface MyPanelsController : JASidePanelController
@end
#import "MyPanelsController.h"
@implementation MyPanelsController
-(void)awakeFromNib
{
[self setLeftPanel:[self.storyboard instantiateViewControllerWithIdentifier:@"leftViewController"]];
[self setCenterPanel:[self.storyboard instantiateViewControllerWithIdentifier:@"centerViewController"]];
[self setRightPanel:[self.storyboard instantiateViewControllerWithIdentifier:@"rightViewController"]];
}
@end
And in your storyboard drag a UIViewController
and set its class to MyPanelsController
and set it as the initial view controller.