将我的项目从纵向转换为横向的问题

时间:2011-03-04 08:10:31

标签: iphone objective-c cocoa-touch ipad uiinterfaceorientation

我以纵向开发了我的项目,现在我想在横向上设置我的项目方向。我已将所有xib文件的orientation属性设置为landscape,而在.plist中我也将Supported支持接口方向的所有项目设置为landscape,但是当我运行我的项目时,一个视图仍然以纵向方向显示...在此视图中我显示pdf文件。

提前致谢!!!

2 个答案:

答案 0 :(得分:2)

您是否在视图控制器中放置了以下方法

- (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
    return YES;
}

答案 1 :(得分:1)

如果Landscape使用此代码

(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
    return (interfaceOrientation==UIInterfaceOrientationLandscapeLeft || interfaceOrientation==UIInterfaceOrientationLandscapeRight);
}

如果Portrait使用此代码

(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
    return (interfaceOrientation==UIInterfaceOrientationPortrait || interfaceOrientation==UIInterfaceOrientationPortraitUpsideDown);
}