旋转设备时,我的应用程序出现问题。 tableView 扩展到设备 View ,导致无法访问。
如何让表格调整大小,以免发生这种情况?
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft ||
toInterfaceOrientation == UIInterfaceOrientationLandscapeRight)
{
NSLog(@"Device is rotated sidewise");
myTable.delegate = self;
myTable.dataSource = self;
myTable.scrollEnabled = YES;
[self.view addSubview:myTable];
myTable = [[UITableView alloc] initWithFrame:CGRectMake(0, 148, 320, 10)];
}
}
在使用 xcode 或 objective-c 进行编码时,我完全是个菜鸟。我目前正在研究这个,所以请对你的回答保持友好。
最佳答案
尝试使用自动调整大小蒙版,不要在方向上设置框架。使用下面的链接了解自动调整大小。使用自动调整大小,您无需以编程方式编写任何代码。 http://www.techpaa.com/2012/05/understanding-uiview-autoresizing.html
关于ios - 旋转设备时调整 tableView 的大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21622939/