开发者

Is there a way to make a UITableViews sections handle touch events?

开发者 https://www.devze.com 2023-02-28 16:19 出处:网络
Is there a simple way or methods for allowing touches to be handled in sections(headings) and to track which section(heading) was touched?

Is there a simple way or methods for allowing touches to be handled in sections(headings) and to track which section(heading) was touched?

I only 开发者_运维知识库want to draw the cells for a section when the user presses that section. But i want all the sections to always be visible.

I know i can hack that by make the headings be represented as cells and then draw extra cells below that cell when its touched. But its kinda hacky i guess.

Thanks, Code


An easy way is to provide a custom section header view for your table view that contains some control, like a button, that can handle those touches for you.

Take a look at UITableViewDelegate's viewForHeaderInSection: method. You can use the section number that comes from that method to identify which section of cells to reveal as the user touches a button in that section header view.

0

精彩评论

暂无评论...
验证码 换一张
取 消