JASidePanels-2 Example Using a Storyboard: Crash

I am trying to implement JASidePanels example2 using a 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 the above code to CenterViewController.m, which was the same as MySidePanelController.m in example2, the application crashed, as shown below.

https://dl.dropboxusercontent.com/u/6655378/stack1.png

 -(void)awakeFromNib { // [self setLeftPanel:[self.storyboard instantiateViewControllerWithIdentifier:@"leftViewController"]]; // [self setCenterPanel:[self.storyboard instantiateViewControllerWithIdentifier:@"centerViewController"]]; // [self setLeftPanel:[self.storyboard instantiateViewControllerWithIdentifier:@"rightViewController"]]; } 

If I commented as shown above, the application works as shown below. ttps: //dl.dropboxusercontent.com/u/6655378/stack2.png

I am new to iOS. Could you tell me what is wrong?

My environment.

  • Xcode: version 4.6.2
  • IOS SDK: 6.1
  • Simulator: iPhone 6.1
+4
source share
1 answer

You call stackoverflow by calling the code in -awakeFromNib in its central view, as it sets another central controller as the central panel and goes that way until the application runs.

You should have a subclass of JASidePanelController , where you implement -awakeFromNib and 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 the UIViewController and set its class to MyPanelsController and set it as the initial view controller.

+5
source

Source: https://habr.com/ru/post/1479379/


All Articles