cell里面
typedef void(^ TouXiang)(NSString *); // 文章ID
@property (nonatomic, copy) TouXiang myTouXiang; // 传文章ID的Block
-(void)tapAction{
NSLog(@"点击了头像。");
self.myTouXiang(@"1");
}
tablvew 里面:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellIdentifier = @"cell";
Comment_Cell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell == nil) {
cell = [[Comment_Cellalloc] initWithStyle:UITableViewCellStyleDefaultreuseIdentifier:cellIdentifier];
}
///最好放在这里。。。
cell.myTouXiang = ^(NSString *tempS){
if (self.isMyComment) {
MyCommentModel *myCommentModel = _myComment_dataArr[indexPath.row];
self.articl_id = myCommentModel.comment_id;
self.pinglunID = myCommentModel.cmted_user_id;
} else {
CommentMe *commentMeModel = _commentMe_dataArr[indexPath.row];
self.articl_id = commentMeModel.comment_id;
self.pinglunID = commentMeModel.cmt_user_id;
}
MySendOutViewController *sendVC = [[MySendOutViewControlleralloc]init];
sendVC.friend_user_id = self.pinglunID;
[self.viewController.navigationControllerpushViewController:sendVC animated:YES];
};
本文介绍了一种在iOS应用中使用TableView时,通过Block实现头像点击事件并传递文章ID的方法。具体实现了当点击单元格内的头像时,会触发一个Block,并通过该Block传递指定的文章ID。
476

被折叠的 条评论
为什么被折叠?



