UIView 方向以编程方式更改

发布于 2024-09-24 20:56:12 字数 93 浏览 0 评论 0原文

我有 uiview,其中添加了 uiviewtablecontroller 作为子视图,我的设备以横向模式启动,但 tableviewcontroller 始终处于纵向模式

i have uiview with a uiviewtablecontroller added as subview, my device starts in landscape mode but tableviewcontroller is always in the portrait mode

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

风启觞 2024-10-01 20:56:12

下面的方法“return yes”将会改变方向,如果是“return NO”则方向不会改变。在您的视图中使用此方法。

- (BOOL) shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation) orientation 
{

return YES;

}

一切顺利。

The below method "return yes" will make orientation change if it is "return NO" the orientation will not change.Use this method in your view.

- (BOOL) shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation) orientation 
{

return YES;

}

All the best.

空‖城人不在 2024-10-01 20:56:12

我的沙箱应用程序:
接口(h 文件)中的https://github.com/comonitos/programatical_device_orientation

    BOOL rotated;

实现中(m 文件 ) ):

    -(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
    {
    return rotated;
    }
    -(void) setup 
    {
    rotated = YES;
    [[UIDevice currentDevice] setOrientation:UIDeviceOrientationLandscapeLeft];
    rotated = NO;
    }

My sandbox app:
https://github.com/comonitos/programatical_device_orientation

in interface (h file) :

    BOOL rotated;

in implementation (m file):

    -(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
    {
    return rotated;
    }
    -(void) setup 
    {
    rotated = YES;
    [[UIDevice currentDevice] setOrientation:UIDeviceOrientationLandscapeLeft];
    rotated = NO;
    }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文