首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > Iphone >

怎样设置横屏?解决思路

2012-05-22 
怎样设置横屏?有这一段代码:MyViewController *_main [[[MyViewController alloc] init]autorelease]_n

怎样设置横屏?
有这一段代码:
MyViewController *_main = [[[MyViewController alloc] init]autorelease];
_navController = [[UINavigationController alloc] initWithRootViewController:_main];

MyViewController的Class类里面重写了shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation实现了横屏不能竖屏,
MyViewController的xib文件里面,orientation属性设置横向。

现在问题是我通过上面代码放到一个UINavigationController 内,运行结果是UINavigationController是竖屏的,而MyViewController是横屏的,而且不能旋屏了。

我把MyViewController的xib文件里面,orientation属性设置为默认值后,也把shouldAutorotateToInterfaceOrientation注释掉,还是出现那个情况,不能旋屏;

但如果我吧_navController = [[UINavigationController alloc] initWithRootViewController:_main];这句注释掉,就可以了,但你这样我没了UINavigationController 了。

求解决办法

[解决办法]
你是不是 想运行后开始只出现横屏 然后还能旋屏 ?
如果这样的话 只在 ios sdk 里summary选项 中 supported Device Orientations 有四个显示屏的选项 
把它只保留横屏就行

不用 在MyViewController的Class类里面重写了shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
[解决办法]
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return YES;
}

LZ给分。
[解决办法]
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation==UIInterfaceOrientationLandscapeLeft) || (interfaceOrientation==UIInterfaceOrientationLandscapeRight);
//return YES;
}

热点排行