各位大侠好,请教一个问题:
我需要在代码中强制性地旋转到一个特定方向
ios5以后不能直接使用setOrientation方法了,找了网上的贴子说可以通过下面的代码实现
if ([[UIDevice currentDevice] respondsToSelector:@selector(setOrientation:)]) {
        [[UIDevice currentDevice] performSelector:@selector(setOrientation:)
                                       withObject:(id)UIInterfaceOrientationLandscapeRight];
    }
由于使用了ARC,系统会提示
Cast of 'int' to 'id' is disallowed with ARC
尝试了一些修饰词都还是不行,请大侠指点

解决方案 »

  1.   

    buildseting --搜auto 然后把object-c++ auto...设置no
      

  2.   

    设置为no的话内存都需要手工管理了吧,那样写代码会麻烦很多哦,ios5以后应该也还是有可以直接处理的方法吧,谢谢!
      

  3.   

    你看看这是哪个文件,可以设置某个文件不适用ARC的。
    在target中的compile sources中,将该文件指定成-fno-objc-arc
    就可以了
      

  4.   

    你好,请问有没办法在使用arc的情况下调用上面的函数呢?
      

  5.   

    还是cocoachina上高手多些,终于解决了,贴上来做个记号,一个叫maxwin的大帅解决的    if ([[UIDevice currentDevice] respondsToSelector:@selector(setOrientation:)]) {
            SEL selector = NSSelectorFromString(@"setOrientation:");
            NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[UIDevice instanceMethodSignatureForSelector:selector]];
            [invocation setSelector:selector];
            [invocation setTarget:[UIDevice currentDevice]];
            int val = UIInterfaceOrientationLandscapeRight;
            [invocation setArgument:&val atIndex:2];
            [invocation invoke];
        }
      

  6.   

    [NSNumber numberWithInteger:UIInterfaceOrientationLandscapeRight]