-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath还想拿到cell的row 的话 我们可以这样实现 ,下面把 我的代码贴出来
首先 写个协议
@protocol MyIntroduceCellDelegate <NSObject>
协议里面有这个方法
- (void)MyIntroduceCell:(MyIntroduceCell *)cell
@property (nonatomic, assign) id <MyIntroduceCellDelegate>delegate;
完了 我们可以再cell 上写个button 让他UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect ];
[button setFrame:CGRectMake(250, 23, 40, 40)];
[button setTitle:@"购买" forState:UIControlStateNormal];
[button addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
- (void)buttonAction:(id)sender{
if ([self.delegate respondsToSelector:@selector(MyIntroduceCell:)]) {
[self.delegate MyIntroduceCell:self];
}
}
响应这个方法
然后在我们的tableView 那实现这个协议的方法
- (void)MyIntroduceCell:(MyIntroduceCell *)cell{
NSIndexPath *indexPath = [self.introduce indexPathForCell:cell];
x= ++x;
NSLog(@"==countNum==%i",++countNum);
[scale addObject: [self.saleArray objectAtIndex:indexPath.row]];
[adress addObject:[self.addressArray objectAtIndex:indexPath.row]];
[jing addObject:[self.fengMianName objectAtIndex:indexPath.row]];
}
这样就拿到cell 的row 了