Reload section without reloading section header

后端 未结 7 592
离开以前
离开以前 2020-12-08 08:03

I have a UITableView, where there is a UISegmentedControl in the header view. It should work exactly like in the App Store app: As the user scrolls

7条回答
  •  悲&欢浪女
    2020-12-08 08:18

    Try this:

    BOOL needsReloadHeader = YES;
    UIView *oldHeaderView = nil;
    
    -(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
        UIView *headerToReturn = nil;
        if(needsReloadHeader == YES) {
            headerToReturn = [[UIView alloc] init];
            // ...
            // custom your header view in this block
            // and save
            // ...
            oldHeaderView = headerToReturn;
        } else {
            headerToReturn = oldHeaderView;
        }
        return headerToReturn;
    }
    

    Your just need to change 'needsReloadHeader' to 'NO' in other places.

提交回复
热议问题