nitz19arg
nitz19arg

Reputation: 427

UISearchBar not moving with Tableview when scrolling down

UISearchBar is not moving with Tableview when scrolling down.

I don't want to separately place the scrollbar. Its a requirement. Below is the code.

customSearchBar = [[UISearchBar alloc] init];
customSearchBar.delegate = self;
[customSearchBar sizeToFit];
objListTable.tableHeaderView = customSearchBar;

Upvotes: 1

Views: 444

Answers (1)

Madhu
Madhu

Reputation: 1542

Need to include a View and add UISearchbar on it, or else provide height of the Header view. By default its treats as 0.0.

If you want to use

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section

the method allocate a View with height of default UISeachBarheight. and add UISearchBaron it.

Or else add a UIView on your code with default UISearchBar height add UISearchBar on it. It will works as you expected.

Upvotes: 1

Related Questions