ios仅限分享图片

时间:2015-10-29 03:24:09

标签: ios orientation ios8-share-extension

我需要将共享扩展限制为仅限纵向模式。但到目前为止,这还不行。有办法吗?

@implementation UINavigationController

-(BOOL)shouldAutorotate
{
     return UIInterfaceOrientationMaskPortrait;
}

-(NSUInteger)supportedInterfaceOrientations
{
     return UIInterfaceOrientationMaskPortrait;
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
     return UIInterfaceOrientationPortrait;
}

1 个答案:

答案 0 :(得分:1)

您可以像answer here

一样扩展UIScreen

并在

中表演
   - (void)viewDidLayoutSubviews of UIViewController.

answer here

中的内容

来自第一个链接的代码与Objective-C中的代码相似:

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

}