Jonathan Chiu
Jonathan Chiu

Reputation: 1677

How do I get a disclosure indicator in my tableview header section?

I'm customizing my headers in my Tableview and I want to add a discloure indicator (arrow) to my header that is clickable, is that possible?

Upvotes: 0

Views: 1614

Answers (2)

faris.halteh
faris.halteh

Reputation: 71

You can fetch the header view using

- (void)tableView:(UITableView *)tableView willDisplayHeaderView:(UIView *)view forSection:(NSInteger)section

Then fetch the actual header view

UITableViewHeaderFooterView *header = (UITableViewHeaderFooterView *)view;

Create a button with detail disclosure

UIButton *button = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];

Then set the frame of this button and add it to the header view

Upvotes: 0

shannoga
shannoga

Reputation: 19869

If you already customized your header view you can simply add a custom UIButton with an image of a discloure indicator add add it as a subview to your header view.

If you need further help you are most welcome.

EDIT Jonathan is right, the UIButton has a UIButtonTypeDetailDisclosure so there is no need for a custom image.

Upvotes: 1

Related Questions