【问题标题】:table view dissappears when changing from portrait to landscape view xcode从纵向视图更改为横向视图xcode时表格视图消失
【发布时间】:2011-07-19 16:39:40
【问题描述】:

我正在开发一个顶部有地图视图,底部有表格视图的项目,我尝试使用以下代码使应用程序可调整为不同的视图方向,

- (BOOL)shouldAutorotateToInterfaceOrientation:      
(UIInterfaceOrientation)interfaceOrientation
{


    return YES;
}

但是当我将视图从纵向视图更改为横向视图时,表格视图消失了, 我怎样才能使这项工作,任何帮助将不胜感激

提前谢谢你,

【问题讨论】:

    标签: uitableview xcode4 uiinterfaceorientation


    【解决方案1】:

    表格视图在横向视图中隐藏在下方,我必须对表格视图的位置和高度进行硬编码,以使其在纵向和横向视图中显示在相同的高度和位置

    - (BOOL)shouldAutorotateToInterfaceOrientation:     (UIInterfaceOrientation)interfaceOrientation
    {
     if (UIInterfaceOrientationIsLandscape([UIDevice currentDevice].orientation)) {
         CGRect tableViewFrame = [tableView frame];
         tableViewFrame.origin.x = 0;
         tableViewFrame.origin.y = 500;         
         tableViewFrame.size.height=500;
         [tableView setFrame:tableViewFrame];
     }
     else if (UIInterfaceOrientationIsPortrait([UIDevice currentDevice].orientation)){
         CGRect tableViewFrame = [tableView frame];
         tableViewFrame.origin.x = 0;
         tableViewFrame.origin.y = 755;         
         tableViewFrame.size.height=500;
         [tableView setFrame:tableViewFrame];
     }
    
    return YES;
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多