我做了一個表,內容有一些價值觀,我有一個按鈕編碼像如何通過單擊按鈕(定位到方法)來獲取特定行的索引?
cell.textLabel.textColor = [UIColor whiteColor];
UIButton *btn=[UIButton buttonWithType:UIButtonTypeCustom];
[btn setBackgroundColor:[UIColor clearColor]];
[btn setBackgroundImage:[UIImage imageNamed:@"edit_button.png"] forState:UIControlStateNormal];
[btn setFrame:CGRectMake(290, 15, 15, 15)];
[btn addTarget:self action:@selector(editTable:)
forControlEvents:UIControlEventTouchUpInside];
[cell.contentView addSubview:btn];
NSString *cellValue = [myArrayNew objectAtIndex:indexPath.row];
cell.textLabel.text = cellValue;
return cell;
我想點擊該按鈕,並從該特定指數取值,
像
阿里(按鈕在這裏)--------索引0 Sajid(button here)-------- index 1 Robert(button here)-------- index 2 RaM(button here )-------- index 3
Theser是表的單元格,現在如何獲取索引,因爲我單擊該按鈕?
,如果你沒有得到我的問題,你可以再問我......
可能重複http://stackoverflow.com/questions/1802707/detecting-which-uibutton-was-pressed-in -a-uitableview) – Vladimir 2011-02-17 09:47:55