方法一:
用文本编辑工具 打开工程属性文件,也就是那个 xx-info.plist文件,把下面蓝色的部分复制进去,保存。重新编译下,OK。
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"><plist version="1.0">
<dict>
<key>UIInterfaceOrientation</key>
<string>UIInterfaceOrientationLandscapeRight</string>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationLandscapeRight</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
</array>
</dict>
</plist>
方法二:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
//return (interfaceOrientation == UIInterfaceOrientationPortrait);
//只支持横屏
if(UIInterfaceOrientationIsLandscape(interfaceOrientation))
{
return YES;
}
/*else//只支持竖屏
if(UIInterfaceOrientationIsPortrait(interfaceOrientation))
{
return YES;
}
*/
return NO;
}