Apple会接受以下代码吗?
[[UIDevice currentDevice] setOrientation:UIInterfaceOrientationPortrait];
当我写这篇文章时,我看到以下警告:
警告:'UIDevice'可能无法响应'-setOrientation:'
那么我该如何以编程方式设置iPhone的方向呢?
答案 0 :(得分:1)
撰写[[UIDevice currentDevice] set ];
后,您是否找到了setOrientation
的选项?绝对是私有API。不要使用它。
答案 1 :(得分:1)
你应该阅读this Stack Overflow question的答案。它与很多关于如何处理方向以及如何应对的代码片段进行了长时间的讨论。
答案 2 :(得分:0)
不,Apple拒绝使用此代码的应用程序。
答案 3 :(得分:0)
只需在.h或.m文件中的某个类别中声明该方法即可。
@interface UIDevice (MyPrivateNameThatAppleWouldNeverUseGoesHere)
-(void) setOrientation:(UIInterfaceOrientation)orientation;
@end
但Apple也拒绝使用此代码的应用程序。 所以,使用它来解决调用orienatation方法..它工作正常
UIViewController * viewController = [[UIViewController alloc] init];
[viewController setModalPresentationStyle:UIModalPresentationCurrentContext];
viewController.view.frame = CGRectZero;
[self presentModalViewController:viewController animated:NO];
[self dismissModalViewControllerAnimated:NO];
[viewController release];
抱歉,如果有任何错误。我是iphone的新手...... :)