开发者社区> 问答> 正文

关于在WeeApp中的横屏模式

需要横屏模式下,在widget中心做一个标签。

[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
if (([[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeLeft) ||
    ([[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeRight))
{
     d = 516; //my var to change the Position (The Value is just a test)
}

不知道为什么没实现。

展开
收起
爵霸 2016-03-19 11:15:00 1809 0
1 条回答
写回答
取消 提交回答
  • AppController定义这个方法:

    - (void)willAnimateRotationToInterfaceOrientation:(int)arg1

    然后检测方向:

    if (UIInterfaceOrientationIsLandscape(arg1)) {
        // you're in landscape mode
        float screenWidth = [UIScreen mainScreen].bounds.size.height;
    }
    else {
        // you're in portrait mode
        float screenWidth = [UIScreen mainScreen].bounds.size.width;
    }
    2019-07-17 19:07:45
    赞同 展开评论 打赏
问答地址:
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载