如何设置tableView动态的高度?

时间:2016-07-04 05:16:42

标签: ios objective-c uitableview

我有一个动态细胞计数的tableview。我对桌面视图的高度有困难。 tableview确实滚动,但它不会一直向下到最后一个单元格,它可以,但我需要点击tableview并一直向下滚动,当我释放点击它将返回。

这是我如何实现它

UIInterfaceOrientation newOrientation =  [UIApplication sharedApplication].statusBarOrientation;
if(newOrientation == UIInterfaceOrientationLandscapeLeft || newOrientation == UIInterfaceOrientationLandscapeRight)
{

    _logoView = [[UIView alloc] initWithFrame:CGRectMake(0,0,self.view.bounds.size.width/2.3, self.view.bounds.size.height/3)];
    self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(self.view.bounds.size.width/2.3, 0, self.view.bounds.size.width - self.view.bounds.size.width/2.3, self.view.bounds.size.height + self.view.bounds.size.height)];


}

else if (newOrientation == UIInterfaceOrientationPortrait || newOrientation == UIInterfaceOrientationPortraitUpsideDown)
{

    _logoView = [[UIView alloc] initWithFrame:CGRectMake(0,0,self.view.bounds.size.width, self.view.bounds.size.height/4)];
    self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, self.view.bounds.size.height/4, self.view.bounds.size.width, self.view.bounds.size.height)];
}
imageView.frame = _logoView.bounds;
[_logoView addSubview:imageView];


self.tableView.dataSource = self;
self.tableView.delegate = self;
[self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cells"];
[self.view addSubview:self.tableView];

当我以纵向方式将另一个self.view.bounds.height添加到tableview的高度时,tableview变得更小

1 个答案:

答案 0 :(得分:0)

解决了它。我的错。我的UITableView高度超过了。降低它的高度,它现在正常工作

相关问题