我沒有一個完整的答案給你,我不知道爲什麼你的第一行是在導航欄下面,也許你應該提供額外的代碼或屏幕截圖。
在最糟糕的情況下,我會做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