JASidePanels,设备是横向的,但面板仍然是纵向的

时间:2013-10-31 11:07:49

标签: ios objective-c uiview

我正在使用JASidePanels。我已将我的项目和故事板设置为仅以横向显示。结果如下所示。 JASidePanels似乎将视图视为肖像。但是,当我将设备转到另一侧时,面板方向将得到纠正。请告知如何解决此问题。

感谢。

enter image description here

3 个答案:

答案 0 :(得分:1)

您可以在viewDidAppear()中添加以下行:

[self _layoutSideContainers:YES duration:0];

答案 1 :(得分:0)

尝试用以下方法替换 - (void)_layoutSidePanels方法:

 - (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);
}
}

请给我一个反馈,我不确定这是不是问题

答案 2 :(得分:0)

我想我找到了解决方案。我将viewDidLoad()中的以下代码替换为viewDidAppear()。问题是在视图出现后,它将获得正确的视图宽度。

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];