私の iPhone アプリケーションでは、各セルにアクセサリ ボタンを追加しました。
以下は私のコードです:
ContactCell *contactCell = (ContactCell *)[tableView dequeueReusableCellWithIdentifier:kCellID];
if (contactCell == nil) {
contactCell = [[ContactCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:kCellID];
contactCell.frame = CGRectMake(0.0, 0.0, 320.0, ROW_HEIGHT);
}
UIImage *callButtonImage=[UIImage imageNamed:@"call-person.png"];
UIButton *button =[UIButton buttonWithType:UIButtonTypeCustom];
button.frame=CGRectMake(0.0, 0.0, 200, ROW_HEIGHT);
[button setBackgroundImage:callButtonImage forState:UIControlStateNormal];
ContactWrapper *cellWrapper = nil;
[button addTarget:self action:@selector(askCallForClientContact:) forControlEvents:UIControlEventTouchUpInside];
contactCell.accessoryView = button;
ボタンフレームを次のように設定しました。button.frame=CGRectMake(0.0, 0.0, 200, ROW_HEIGHT);
しかし、ボタンフレームは200未満のようです。セルをクリックしてボタンがあると仮定すると、didSelectRowAtIndexPath
イベントではなくaskCallForClientContact:
イベントが表示されます。アクセサリーボタンの枠を設定するには?200幅にする必要がありますか?