Andrey Chernukha
Andrey Chernukha

Reputation: 21808

Calculating actual size of UITableView

I need to scroll my UITableWay programmatically. Scrolling is performed when user touches a button. I want my UITableWay scroll up until the bottom of the actual table reaches the bottom of the table's frame. I thought it would be easy to implement by doing something like this:

static CGFloat offset;

- (IBAction)pageUpClick:(id)sender
{
if (offset < ([rankingTableView numberOfRowsInSection:[rankingTableView numberOfSections] - 1] * rankingTableView.rowHeight) - rankingTableView.frame.size.height)
     {
       offset += 10.0;
       [rankingTableView setContentOffset:CGPointMake(0, offset)];
      }
 }

but it doesn't work. The table just goes up even when the rows are over the bottom of the frame. i cannot find the actual size of my table.... but obviously it is quantity of rows * row height. since i want my scrolling stop when both the bottom of the table and the bottom of its frame lies on the same line i'm substracting the height of the frame. And all in vain. My only possible explanation is maybe i'm using wrong section number (i'm assuming it to be [rankingTableView numberOfSections] - 1 cause i got just one section ) ... but how can i check it? Any ideas? Thanks in advance

Upvotes: 0

Views: 1780

Answers (1)

beryllium
beryllium

Reputation: 29767

What about contentSize property? Try this:

CGSize mySize = [myTableView contentSize];

Upvotes: 8

Related Questions