ios中强制一个Viewcontorller横竖屏

    SEL selector = NSSelectorFromString(@"setOrientation:");
    NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[UIDevice instanceMethodSignatureForSelector:selector]];
    [invocation setSelector:selector];
    [invocation setTarget:[UIDevice currentDevice]];
    int val = UIDeviceOrientationLandscapeLeft;
    [invocation setArgument:&val atIndex:2];//前两个参数已被target和selector占用
    [invocation invoke];

执行这段代码  会重新执行返回屏幕方向的方法

 

 

你可能感兴趣的:(cocos2dx学习)