代码之家  ›  专栏  ›  技术社区  ›  Coocoo4Cocoa

为什么我的UITableView不占据屏幕边界?

  •  1
  • Coocoo4Cocoa  · 技术社区  · 16 年前

    我正在以编程方式构建一个不带NIB文件的UITableView。不过,我在做一些傻事,因为我的导航栏显示得很好,我的UITableView也显示得很好。但是,uiTableView未正确安装到屏幕上。您将看到大约20个像素分隔uinavigationbar和uitableview。我将窗口背景色设置为黑色,如您在此屏幕截图中所见:

    enter image description here

    下面是重现问题的代码:

    - (void)loadView
    {
        [super loadView];
        // TableViews that wish to utilize tableView footers/headers should override this method.
    
        UITableView *aTableView = [[UITableView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame] style:UITableViewStylePlain];
        aTableView.autoresizingMask = (UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight);
        aTableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
    
        aTableView.delegate = self;
        aTableView.dataSource = dataSource;
    
        self.tableView = aTableView;
        [self.view addSubview:self.tableView];
        [aTableView release];
    
        // style navigation bar.
        //self.navigationController.navigationBar.barStyle = UIBarStyleBlackOpaque;
    }     
    
    1 回复  |  直到 14 年前
        1
  •  1
  •   CiNN    16 年前

    使用边界而不是ApplicationFrame

    推荐文章