Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UITableView won't bounce back after scrolling down past screen

Here's a video of what's going on: https://imgflip.com/gif/kgvcq

Basically, if the cells scroll past the bottom edge of the screen, it won't bounce back. I've tried updating the contentSize of the tableView but that doesn't seem to be the issue. I've also made sure to declare the rowHeight and still no luck. Lastly, I've made sure the bounce properties of the tableView are set properly.

Sorry for not putting up code, here it is:

// data source
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSLog(@"frame height: %f", tableView.frame.size.height);
    NSLog(@"content size height: %f", tableView.contentSize.height);

    static NSString *CellIdentifier = @"HabitCell";

    HabitTableViewCell *cell = (HabitTableViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    cell.viewController = self;
    cell.delegate = self;

    // edit cell

    return cell;
}

The NSLogs are returning: 568 and 400 respectively. Would it be the frame causing problems? Also, I have not overridden scrollViewDidScroll.

Implemented Data Source Methods

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    // Return the number of rows in the section.
    return [self.habits count];
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    if ([indexPath isEqual:_expandIndexPath]) {
        return 450 + heightToAdd;
    }
    return 100;
}
like image 262
espitia Avatar asked Apr 21 '15 17:04

espitia


1 Answers

Fixed: I had a call to scrollToRowAtIndexPath in my UIPanGestureRecognizer method. Removed it and it now works perfectly.

like image 158
espitia Avatar answered Oct 13 '22 00:10

espitia