How to position UITableViewCell at bottom of screen?

前端 未结 14 602
旧时难觅i
旧时难觅i 2020-12-08 03:25

There are one to three UITableViewCells in a UITableViewView. Is there a way to always position the cell(s) at the bottom of screen after rel

14条回答
  •  旧时难觅i
    2020-12-08 03:27

    USE THIS. Surely this will help.

    - (void)reloadData
    {
        [super reloadData];
    
        [self recalculateContentInset];
        [self recalculateScrollIndicator];
    }
    
    - (void)recalculateContentInset
    {
        CGFloat contentInsetHeight = MAX(self.frame.size.height - self.contentSize.height, 0);
        CGFloat duration = 0.0;
        [UIView animateWithDuration:duration
                              delay:0
                            options:UIViewAnimationOptionCurveEaseOut
                         animations:^{
            [self setContentInset:UIEdgeInsetsMake(contentInsetHeight, 0, 0, 0)];
        }completion:nil];
    }
    
    - (void)recalculateScrollIndicator
    {
        if(self.contentSize.height >= self.frame.size.height){
            [self setShowsVerticalScrollIndicator:YES];
        } else {
            [self setShowsVerticalScrollIndicator:NO];
        }
    }
    

提交回复
热议问题