各位大侠好,请教一个问题:
我需要在代码中强制性地旋转到一个特定方向
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
尝试了一些修饰词都还是不行,请大侠指点
我需要在代码中强制性地旋转到一个特定方向
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
尝试了一些修饰词都还是不行,请大侠指点
解决方案 »
- 从SQLITE读出纪录如何按照字母分组显示在TableView中
- 在IOS中如何自己控制弹出的UIAlertView窗口是否消失
- xcode4下C++静态库调不起来 ,已解决,接分速来。
- ipad发送邮件的时候,收件人没有收到邮件是怎么回事????
- UIslider设置Thumb的图片的问题
- 求助大家一个关于UIpickerView的问题
- 高德地图反向解析的地址怎么是英文的!怎么转中文地址?
- 发布APP后 删除证书会有什么影响
- uiimageView 中图片显示问题,请大神们帮忙看看
- 美国 Big Nerd Ranch 高级 iOS 培训总结(下)
- MAC系统下的SCPlugin不能Checkout怎么解决?Server sent unexpected return value (403 Forbidden
- 多个View的调用?
在target中的compile sources中,将该文件指定成-fno-objc-arc
就可以了
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];
}