开发者

iPhone - how may I catch a button click in a header view into a UITableView

开发者 https://www.devze.com 2023-02-06 17:20 出处:网络
I\'m planning to build a cust开发者_开发问答omized view for the header line of a table view, with a button inside it. I think there will be no problem to do that, but I guess how I\'ll be able later t

I'm planning to build a cust开发者_开发问答omized view for the header line of a table view, with a button inside it. I think there will be no problem to do that, but I guess how I'll be able later to know from wich header line the button was clicked ? I guess that didSelectRowAtIndexPath will not be usefull here, and I don't see any didSelectHeaderAtSection method...

Can you tell me a good way to do that stuff ?

Thank you


I did that once and used the indexPath.row integer, passed that to the (id) sender of the button. That should work just fine.

Edit:

In:

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

you create a button. Then you can do this:

button.tag = section;

You attach a method to the buttons

- (void) myMethod:(id) sender  

and inside there should be something like this:

[(UIButton *)sender tag]

That should do the job.

0

精彩评论

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