【发布时间】:2011-01-25 16:29:05
【问题描述】:
我从来没有玩过 iPhone 是横向的,但我有一个功能齐全的 iPhone 应用程序,它假设用户正在直立查看 iPhone。我想玩转手机,为了做到这一点,我做了一些非常简单的事情:
我将以下代码添加到我的视图控制器中:
-(void)willRotateToInterfaceOrientation: (UIInterfaceOrientation)orientation duration:(NSTimeInterval)duration {
NSLog(@"WILL ROTATE TO INTERFACE ORIENTATION: %@",orientation);
if ((orientation == UIInterfaceOrientationLandscapeLeft) || (orientation == UIInterfaceOrientationLandscapeRight))
tableView.frame = CGRectMake(0, 0, 480, 320);
else
tableView.frame = CGRectMake(0,73,320,390);
}
我收到 BAD_ACCESS 错误。我根本看不到视图负载。那么,问题出在哪里,如何正确实现 willRotate 方法,以便在手机旋转时,我可以调整所有组件的大小?
【问题讨论】:
-
这不是太多的代码。 EXC_BAD_ACCESS 是由于访问不再存在的对象而导致的错误。你的控制台里有什么?它究竟是什么时候发生的?
标签: iphone ios uiview uiviewcontroller rotation