我試圖添加按鈕,進入我的表格單元格象下面這樣:添加按鈕到的UITableViewCell
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
....
UIButton* buttonCheckbox = [UIButton buttonWithType:UIButtonTypeCustom];
buttonCheckbox.frame = CGRectMake(0, 177, 56, 26);
buttonCheckbox.backgroundColor = [UIColor redColor];
[buttonCheckbox addTarget:self action:@selector(actionFirst1) forControlEvents:UIControlEventTouchUpInside];
[buttonCheckbox setTitle:@"MyTitle" forState:UIControlStateNormal];
[cell addSubview:buttonCheckbox];
但actionFirst1事件不被解僱。如果我添加按鈕[self.view addSubview:buttonCheckbox]
而不是[cell addSubview:buttonCheckbox]
它工作正常。爲什麼?
感謝...
通常你的操作方法將有一個sender參數(ID),在這種情況下,選擇將是'@selector(actionFirst1:)' – progrmr