简体   繁体   中英

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

我正在自定义Tableview中的标题,并且想在标题中添加一个Discloure指示器(箭头),这是可能的吗?

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.

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

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