セルのaddSubviewメソッドによって追加され、テーブルビューでお気に入りとお気に入りのフラグを設定する画像のクリックイベントが必要です。このタスクを達成するために、セルの didSelectRowAtIndexPath メソッドは必要ないことに注意してください。以下のコードを参照してください:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (!cell) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
UIImage *myImage = [[UIImage alloc]init];
myImage = [UIImage imageNamed: @"Favourite.png"];
UIImageView *imgName = [[UIImageView alloc]initWithImage:myImage];
imgName.frame = CGRectMake(270, 10, 25, 25);
[cell addSubview:imgName];
cell.textLabel.text = @"Hello";
return cell;
}
imgName でクリックイベントを取得するにはどうすればよいですか?