简体   繁体   中英

How reload particular section in UITableview?

When I tried to reload particular section table view scrolls in top direction automatically and I can't understand what is happening?And I used this below code.When I tap on any button full table view scroll to top direction.

        [_moviesDetailTableview beginUpdates];
        [_moviesDetailTableview reloadSections:[NSIndexSet indexSetWithIndex:1]withRowAnimation:UITableViewRowAnimationNone];
        [_moviesDetailTableview endUpdates];

And you can store content offset of your tableview. and can do something like,

 GPoint contentOffset = _moviesDetailTableview.contentOffset;
 [_moviesDetailTableview beginUpdates];
 [_moviesDetailTableview reloadSections:[NSIndexSet indexSetWithIndex:1]withRowAnimation:UITableViewRowAnimationNone];
 [_moviesDetailTableview endUpdates];
 [_moviesDetailTableview layoutIfNeeded];
 [_moviesDetailTableview setContentOffset:contentOffset];

Try this code,

[self.tableView reloadSection:0 withRowAnimation:UITableViewRowAnimationNone];

- (void) reloadSection:(NSInteger)section withRowAnimation:(UITableViewRowAnimation)rowAnimation {
    NSRange range = NSMakeRange(section, 1);
    NSIndexSet *sectionToReload = [NSIndexSet indexSetWithIndexesInRange:range];                                     
    [self reloadSections:sectionToReload withRowAnimation:rowAnimation];
}

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