Search code examples
iosobjective-ciphonejasidepanels

JASidePanels fix right panel bounds


I am using JASidePanels to show a viewController on the right side of the screen. The controllers are loaded from the Main storyboard in this manner from a JASidePanelController subclass:

-(void)awakeFromNib{

    UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]];

    TRMPracticeViewController *practiceVC = [mainStoryboard instantiateViewControllerWithIdentifier:@"Practice"];
    TRMPracticeSetupViewController *practiceSetup = [mainStoryboard instantiateViewControllerWithIdentifier:@"PracticeSetupVC"];

    [self setCenterPanel:practiceVC];
    [self setRightPanel:practiceSetup];
    [self setRightFixedWidth:practiceVC.view.frame.size.width/3.0f];

}

The TRMPracticeSetupViewController has a fixed frame in the storyboard of 200px x 320 px and I would like to maintain the width once the controller is loaded and added to the side (or at least a width proportional to the size of the screen).

However, once the vc has been loaded and added, its frame is set equal to the center view controller, which has of course the size of the screen. So, the views inside the right vc, go under the center vc because of the auto layout constraints that fix their margin to the container bounds.

How can I fix the right panel bounds width to e.g. 200px ?


Solution

  • JASidePanelController has a method for setting fixed width of either left or right panel. Just add this to your code:

    self.rightFixedWidth = 200.0f;