Apple 会接受以下代码吗?
[[UIDevice currentDevice] setOrientation:UIInterfaceOrientationPortrait];
当我写这篇文章时,我看到以下警告:
警告:“UIDevice”可能不会响应“-setOrientation:”
那么我该怎么做才能以编程方式设置 iPhone 的方向呢?
Apple 会接受以下代码吗?
[[UIDevice currentDevice] setOrientation:UIInterfaceOrientationPortrait];
当我写这篇文章时,我看到以下警告:
警告:“UIDevice”可能不会响应“-setOrientation:”
那么我该怎么做才能以编程方式设置 iPhone 的方向呢?
写完之后[[UIDevice currentDevice] set ];
,你找到选项了setOrientation
吗?绝对是私有 API。不要使用它。
你应该阅读这个 Stack Overflow 问题的答案它有很多关于如何处理方向以及如何处理它的代码片段的长时间讨论。
不,Apple 拒绝使用此代码的应用程序。
只需在您使用它的 .h 或 .m 文件的类别中声明该方法。
@interface UIDevice (MyPrivateNameThatAppleWouldNeverUseGoesHere)
-(void) setOrientation:(UIInterfaceOrientation)orientation;
@end
但苹果也拒绝使用此代码的应用程序。因此,将其用于呼叫定向方法的解决方案..它工作正常
UIViewController *viewController = [[UIViewController alloc] init];
[viewController setModalPresentationStyle:UIModalPresentationCurrentContext];
viewController.view.frame = CGRectZero;
[self presentModalViewController:viewController Animation:NO];
[自我dismissModalViewControllerAnimated:否];
[viewController 发布];
对不起,如果有任何错误。我是 iphone 的新手... :)