建立一个TableViewspa
//0, 0, 414, 700 注意xy 是0 0 哦 UITableView *tab = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 414, 700) style:UITableViewStylePlain]; //设置TableView的背景色 tab.backgroundColor = [UIColor redColor]; //打印tableView的contentInset.top NSLog(@"tableVIew的top%f",tab.contentInset.top); [self.view addSubview:tab];
打印top 为0code
可是导航栏能够看到TableVIew的背景色。 而且第0行在导航栏下面。因此虽然contentInset.top =0 ,但显示的效果却有点不同 。并且确实是自动多了一块额外滚动区域 it
打印也为 0table
可是能够看到 第0行是顶到屏幕最上方显示的, 而且top 也是为0 ,普通控制器中是正常的样子。class
在导航控制器中,当tableView 下面有一个view添加在self.view 上时,此时你在往self.view上添加tableView 会发现它又正常了,真是操蛋啊。代码以下:object
//先添加一个 myView 到 self.view上 [self.view addSubview:myView]; //再添加一个tableView 到 self.view上 [self.view addSubview:self.tableView];
此时显示效果以下:im
能够看到TableView ,默认顶到屏幕最上方显示了top