简体   繁体   中英

UITableView with paging and a UIView on top

I'm having a table view where the cells are the size of the screen. I'm using the paging system. I also have a view at the top of the table view.

When I scroll the first time it scrolls well from the first element (the top UIView) to the next element (the first cell), then I'm scrolling to the next one and everything works well. BUT when I'm scrolling back, it only scrolls back half way (the exact size of the top UIView).

Not sure what I'm doing wrong here. Basically the paging system doesn't scroll the right height.

Edit : here's part of my code that might be relevant

// Enabling the paging system

- (void)viewDidLoad
{
    [super viewDidLoad];

    self.tableView.pagingEnabled = YES;
}

// Setting the height of a cell

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return [[UIScreen mainScreen] bounds].size.height;
}
  • A UITableView with paging enabled will not work as a expected though you set the paging enabled to true.
  • For a UITableView to behave like a page we have to control the Scroll of UITableView.
  • There is a sample code for UITableView with Paging enabed UITableView With Paging Enabled

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM