菜鸟教程小白 发表于 2022-12-13 08:47:00

ios - 在仅纵向应用程序中以横向模式呈现 UIViewController


                                            <p><p>我的应用只是一个肖像。我需要在横向模式下呈现 UIViewController(原因是我正在使用 Core-Plot sdk 在该 ViewController 上绘制图形,因此它需要处于横向模式)。</p>

<p>我尝试了以下方法,效果很好。但问题是,当我关闭横向 ViewController 时,应用无法强制进入纵向模式。</p>

<p> <a href="http://www.sebastianborggrewe.de/only-make-one-single-view-controller-rotate/" rel="noreferrer noopener nofollow">http://www.sebastianborggrewe.de/only-make-one-single-view-controller-rotate/</a> </p>

<p> <a href="http://b2cloud.com.au/tutorial/forcing-uiviewcontroller-orientation/" rel="noreferrer noopener nofollow">http://b2cloud.com.au/tutorial/forcing-uiviewcontroller-orientation/</a> </p>

<p>如何在关闭横向 ViewController 后强制应用变为<strong>仅纵向</strong>模式?</p>

<p>这就是我展示横向 ViewController 并将其关闭的方式。</p>

<pre><code> LineChartViewController *obj = [initWithNibName:@&#34;LineChartViewController&#34; bundle:nil];

;


- (IBAction)btnDonePressed:(id)sender{
    ;
}
</code></pre>

<p>LineChartViewController 的 XIB 处于横向模式。</p>

<p><strong>简单来说,我的应用是纵向的,我想以横向模式显示 CorePlot hostView。</strong> </p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>其实我可以通过旋转 CorePlot hostView 来解决这个问题。该解决方案对于所描述的问题并不完美,但我想把我的解决方案放在这里,因为它解决了我的问题</p>

<pre><code>self.hostView = [(CPTGraphHostingView *) initWithFrame:self.viewGraphBack.bounds];
self.hostView.allowPinchScaling = YES;
;

CGAffineTransform transform =
CGAffineTransformMakeRotation(DegreesToRadians(90));

viewGraphBack.transform = transform;

viewGraphBack.frame = CGRectMake(-285, 0, 568, 320);

;
</code></pre></p>
                                   
                                                <p style="font-size: 20px;">关于ios - 在仅纵向应用程序中以横向模式呈现 UIViewController,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/25056664/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/25056664/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - 在仅纵向应用程序中以横向模式呈现 UIViewController