Reputation: 3043
I have a problem that My UITableView is always scrolled up by maybe the half of Section Header. I have a custom Section Header which is 44 pixel height.
After a scrolling down and release the focus the table view gets to his good position. The bug happes only after init.
here is my viewDidLoad
code :
[self.tableView removeUsslessSeparators];
[self.tableView setEstimatedRowHeight:50];
[self.tableView setEstimatedSectionHeaderHeight:0];
[self.tableView setSectionIndexColor:[UIColor colorWithHexString:@"#000000"]];
[self.tableView setSectionIndexBackgroundColor:[UIColor whiteColor]];
[self.tableView setRowHeight:UITableViewAutomaticDimension];
[self.tableView setSectionHeaderHeight:UITableViewAutomaticDimension];
[self.tableView registerNib:[VOIOrbitContactsListSectionHeader nibRepresentation] forHeaderFooterViewReuseIdentifier:[VOIOrbitContactsListSectionHeader preferredIdentifier]];
[self.tableView registerNib:[VOIOrbitContactCell nibRepresentation] forCellReuseIdentifier:[VOIOrbitContactCell preferredIdentifier]];
self.searchBarController = [VOISearchBarController searchViewControllerWithDelegate:self];
[self containerAddChildViewController:self.searchBarController toContainerView:self.searchControllerContainer useAutolayout:YES];
[self.searchControllerContainerTopOffsetConstraint setConstant:75];
[self.tableViewTopOffsetConstraint setConstant:self.searchControllerContainerTopOffsetConstraint.constant + 4] ;
[self.tableView setContentInset:UIEdgeInsetsMake( self.searchControllerContainerHeightConstraint.constant , 0, 50, 0)];
// CGPoint offset = self.tableView.contentOffset;
// self.tableView.contentOffset = offset;
// [self.tableView setContentOffset:CGPointZero animated:NO];
[self checkIfPlusButtonNeedsToBeHidden];
[NSNotificationCenter addObserverForName:VOCChangeNotificationNameForEntity([VOCOrbit class]) usingBlock:^(NSNotification *note) {
[self.tableView reloadData];
}];
I was trying to use different solutions to scroll down a bit the table view programatically. but none of them works.
Upvotes: 0
Views: 67
Reputation: 54
[self.searchControllerContainerTopOffsetConstraint setConstant:75];
[self.tableViewTopOffsetConstraint setConstant:self.searchControllerContainerTopOffsetConstraint.constant + 4] ;
Dont use the content offsets rather give the position of the table directly to:
[self.table setframe:CGRectMake(0,0,width,height)];
Then, Pass your header frame as Header Of Table
table.tableHeaderView = yourHeaderView;
Hope, this will work for you.
Upvotes: 1