ios cell 与tableview之间传参数block方式
?
?
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];
?? ? ? ?
?
? ??};