首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >仅ios共享扩展画像

仅ios共享扩展画像
EN

Stack Overflow用户
提问于 2015-10-29 11:24:09
回答 1查看 600关注 0票数 3

但到目前为止,这还不是很好。有什么办法吗?

代码语言:javascript
复制
@implementation UINavigationController

-(BOOL)shouldAutorotate
{
     return UIInterfaceOrientationMaskPortrait;
}

-(NSUInteger)supportedInterfaceOrientations
{
     return UIInterfaceOrientationMaskPortrait;
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
     return UIInterfaceOrientationPortrait;
}
EN

回答 1

Stack Overflow用户

发布于 2017-01-03 21:36:11

您可以像在answer here中一样扩展UIScreen

并在其中执行

代码语言:javascript
复制
   - (void)viewDidLayoutSubviews of UIViewController.

类似于answer here中的内容

第一个链接中的代码与Objective-C中的代码类似:

代码语言:javascript
复制
    - (UIInterfaceOrientation) orientation {

CGPoint p = [self.coordinateSpace convertPoint: CGPointZero toCoordinateSpace: self.fixedCoordinateSpace];

if (CGPointEqualToPoint(p, CGPointZero)) {
    return UIInterfaceOrientationPortrait;
} else {

    if (p.x != 0 && p.y != 0) {
        return UIInterfaceOrientationPortraitUpsideDown;
    } else {
        if (p.x == 0 && p.y != 0) {
            return UIInterfaceOrientationLandscapeLeft;
        } else {
            if (p.x != 0 && p.y == 0) {
                return UIInterfaceOrientationLandscapeRight;
            } else {
                return UIInterfaceOrientationUnknown;
            }
        }
    }
}

return UIInterfaceOrientationUnknown;

}

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/33405432

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档