
编辑:我正在使用分段的tablevIEw
这是我的代码:
- (UItableVIEwCell *)tableVIEw:(UItableVIEw *)tableVIEw cellForRowAtIndexPath:(NSIndexPath *)indexPath { PosttableVIEwCell *cell = [tableVIEw dequeueReusableCellWithIDentifIEr:@"cell" forIndexPath:indexPath]; // Configure the cell... [cell.likebutton addTarget:self action:@selector(likebuttonpressed:) forControlEvents:UIControlEventtouchUpInsIDe]; cell.likebutton.tag = indexPath.section; return cell;}-(voID)likebuttonpressed:(UIbutton *)sender { NSLog(@"%d",sender.tag); [sender setTitle:@"pressed" forState:UIControlStatenormal];}解决方法 在PosttableVIEwCell.h中定义一个Delegate @protocol HandleCellinteractionDelegate <NSObject>-(voID) dIDPressbutton:(Nsstring*)action forCell:(UItableVIEwCell *)theCell;@end
在tableVIEw.h中注册为此协议的委托
<HandleCellinteractionDelegate>
在tableVIEw.m文件中添加委托处理程序
- (UItableVIEwCell *)cellForRowAtIndexPath:(NSIndexPath *)indexPath{ // Create cell .... cell.delegate = self; if (self.qObjects current object's selection state == selected) enable button else disable button } 添加协议功能
#pragma mark HandleCellinteractionDelegate
-(voID) dIDPressbutton:(Nsstring*)action forCell:(UItableVIEwCell *)theCell{ // Now here you have access to your cell again. And you can update the cell's button text as needed // Here save selection state in data model.. in self.qObjects <== cell.questionTextVIEw.text = @"bla bla";} 总结 以上是内存溢出为你收集整理的ios – 在UITableView中单击UIButton可点击多个按钮全部内容,希望文章能够帮你解决ios – 在UITableView中单击UIButton可点击多个按钮所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)