1

I'm using a TableView and a Collection View in a Scroll View. I set scrolling disabled in the Table View so i need to change the height of the Table View.

I used this code to get the height, but every height was 0

//NSUInteger tableViewheight = self.videosArray.count * 60;  //60 is the cell height

NSUInteger tableViewHeight = self.videosTableView.contentSize.height;

CGRect frame;
frame = self.videosTableView.frame;
frame.size.height = tableViewHeight;
self.videosTableView.frame = frame;

I also tried the commented code above.

Anyone an idea how i can get the height or what I'm doing wrong?

Thanks.

4

2 回答 2

1

Try this:

heightRateTbl = [myArray count] * 60;

rateTableView.frame = CGRectMake(10, 20, 300, heightRateTbl);  

rateTableView.scrollEnabled = NO;

rateTableView.autoresizingMask = UIViewAutoresizingFlexibleHeight;

[rateTableView reloadData];
于 2013-03-30T12:10:49.190 回答
0

You should have try following code to set frame:-

[self.videosTableView reloadData];
float tableViewHeight = self.videosTableView.contentSize.height;
CGRect frame = self.videosTableView.frame;
self.videosTableView.frame = CGRectMake(frame.origin.x, tableViewHeight, frame.size.width, frame.size.height);
NSLog(@"tableViewheight height = %f",tableViewheight);
NSLog(@"videosTableView height = %f",self.videosTableView.frame.size.height);

Hope it will works for you.

于 2013-03-30T12:08:12.057 回答