RockBaby
RockBaby

Reputation: 381

JASidePanels, device is in landscape but the panel are still in portrait

I'm using the JASidePanels. I have set my project and storyboard to show in landscape orientation only. The result shown as below. It seems like the view are read as portrait by JASidePanels. However when i turn the device into to the other side, the panel orientation will be corrected. Please advise how to fix this issue.

Thanks.

enter image description here

Upvotes: 1

Views: 371

Answers (3)

Seb
Seb

Reputation: 61

You can add the following line in viewDidAppear() :

[self _layoutSideContainers:YES duration:0];

Upvotes: 1

RockBaby
RockBaby

Reputation: 381

I think i found the solution. I replace the following code in viewDidLoad() to viewDidAppear(). The problem is after the view did appear, then it will get the correct view width.

self.centerPanelContainer = [[UIView alloc] initWithFrame:self.view.bounds];
_centerPanelRestingFrame = self.centerPanelContainer.frame;
_centerPanelHidden = NO;

self.leftPanelContainer = [[UIView alloc] initWithFrame:self.view.bounds];
NSLog(@"%f",self.leftPanelContainer.frame.size.width);
self.leftPanelContainer.hidden = YES;

self.rightPanelContainer = [[UIView alloc] initWithFrame:self.view.bounds];
self.rightPanelContainer.hidden = YES;

[self _configureContainers];

[self.view addSubview:self.centerPanelContainer];
[self.view addSubview:self.leftPanelContainer];
[self.view addSubview:self.rightPanelContainer];

self.state = JASidePanelCenterVisible;

[self _swapCenter:nil previousState:0 with:_centerPanel];
[self.view bringSubviewToFront:self.centerPanelContainer];

Upvotes: 0

Durican Radu
Durican Radu

Reputation: 1337

Try replacing the -(void)_layoutSidePanels method with this:

 - (void)_layoutSidePanels {
if (self.rightPanel.isViewLoaded) {
      ....
}
if (self.leftPanel.isViewLoaded) {
    CGRect frame = self.leftPanelContainer.bounds;
    frame.size.width = floorf(self.view.bounds.size.width * self.rightGapPercentage);
    if (self.shouldResizeLeftPanel) {
        frame.size.width = floorf(self.view.bounds.size.width * self.rightGapPercentage);

    }
        self.leftPanel.view.frame = CGRectMake(0, 0, self.view.bounds.size.width * self.rightGapPercentage, self.view.bounds.size.height);
}
}

Please give me a feedback, I'm not sure if this is the problem

Upvotes: 0

Related Questions