cell当中的按钮如何获得cell内容】的更多相关文章

cell当中的btn添加方法 [cell.btn addTarget:self action:@selector(btnClickedwith:) forControlEvents:UIControlEventTouchUpInside]; 然后在btn的点击方法里面 -(void)btnClickedwith:(UIButton *)btn{ UITableViewCell*cell = btn.superview; //这个cell就是btn所在的cell,然后cell当中的内容即可获得 }…
#import "ViewController.h" @interface ViewController () <UITableViewDataSource, UITableViewDelegate> @property (nonatomic, retain) UITableView *tableView; @property (nonatomic, retain) NSMutableArray *allDataArray; @end @implementation Vie…
在自定义UITableViewCell中创建了一个按钮. 想在点击该按钮时知道该按钮所在的cell在TableView中的行数.就是cell的 indexPath.row两种方法都很好.-(IBAction):(id)sender{    NSLog(@"MyRow:%d",[self.table indexPathForCell:((TableViewCell*)[[sender   superview]superview])].row); //这个方便一点点,不用设置tag.   …
在UITableView或UICollectionView的自定义cell中创建一button,在点击该按钮时知道该按钮所在的cell在UITableView或UICollectionView中的行数.就是cell的 indexPath.row,下面以UITableView为例: 有两种方法: -(IBAction):(id)sender { 1. 第一种方法,这个方便一点点,不用设置tag.    NSLog(@"MyRow:%d",[self.table indexPathForC…
实际写项目会碰到各种各样的问题,废话不多说 按钮添加到cell时,根据是直接添加到self还是self.contentView上,在点击方法里找到btn的父视图 我是直接添加到self上,所以只有一层 - (void)btnClicked:(UIButton *)btn { UIView *v =[btn superview]; UICollectionViewCell *cell = (UICollectionViewCell *)v; NSIndexPath *tapIndexPath =…
4.点击Cell中的按钮时,如何取所在的Cell:-(void)OnTouchBtnInCell:(UIButton *)Btu{CGPoint point = btn.center;point = [table convertPoint:point fromView:btn.superview];NSIndexPath* indexpath = [table indexPathForRowAtPoint:point];UITableViewCell *cell = [table cellFor…
这个错误表示:该类方法没有addBtnClick对应的方法: bug的复现:创建一个cell,并且添加一个类方法来赋值,在方法中,给按钮添加一个点击事件(addBtnClick),但是,再实现这个方法时,我是用对象方法,所以会崩,应该改成类方法(即用 “+”): + (WDKAddFriendResultCell *)addFriendCellWithTableView:(UITableView *)tableView { WDKAddFriendResultCell *cell = [tabl…
在section=10:row=1:的UITableView中,每一个cell都带有一个按钮,例如如下的图片一样每一个cell中都有一个“进入店铺的按钮”,但是如果我点击相应的cell要进入对应的店铺如何处理呢?如果用”- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath”这个方法的话会的确可以用“indexPath.section”定位到我点击的是哪一个sectio…
-(void)btnClick:(UIButton *)button{ UITableViewCell *cell = (UITableViewCell *)[[button superview] superview]; // 获取cell的indexPath NSIndexPath *indexPath = [self.tableView indexPathForCell:cell]; NSLog(@"点击的是第%ld行按钮",indexPath.row); }…
一.纯代码自定义不等高cell 废话不多说,直接来看下面这个例子先来看下微博的最终效果 首先创建一个继承UITableViewController的控制器@interface ViewController : UITableViewController创建一个cell模型@interface XMGStatusCell : UITableViewCell再创建微博的数据模型@interface XMGStatus : NSObject 纯代码自定义不等高cell 和前面等高cell的思路是一样的…