我没有一个完整的答案给你,我不知道为什么你的第一行是在导航栏下面,也许你应该提供额外的代码或屏幕截图。
在最糟糕的情况下,我会做tableview分组,并安排-(CGFloat)tableView:(UITableView*)tableView heightForHeaderInSection:(NSInteger)section
或我会从界面生成器中的对象拖放到视图上方的虚拟视图,这种方式第一行不能在导航下酒吧。
总而言之,如果您必须在纵向和横向上显示所有行,您可以检测方向更改并使行高变小或变大。
添加通知在viewWillAppear中功能
-(void)viewWillAppear:(BOOL)animated{
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationChanged:) name:UIDeviceOrientationDidChangeNotification object:nil];}
的方向变化通知此功能取决于方向
- (void)orientationChanged:(NSNotification *)notification{
[self.tableview reloadData];
}
更改行高度和收缩行时的方位改变
//row height
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
if (orientation == UIInterfaceOrientationPortrait || orientation == UIInterfaceOrientationPortraitUpsideDown)
{
//portrait mode view
return 40.0; //play with the value according to your needs
}
else if (orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight)
{
//landscape view
return 30.0; //play with the value according to your needs
}
}
尝试编辑您的问题,很难遵循。 – 2013-04-30 20:27:10
@SpaceDust。我改变了它。这有帮助吗? – RookieAppler 2013-04-30 20:35:46
导航栏是来自导航控制器堆栈还是您只是将导航栏拖到视图中? – 2013-04-30 20:44:26