プログラムで UITableViewCell に追加しているボタンがあり、非常に奇妙な動作をしています。
iOS 6 では、期待どおりに動作します。iOS 5x では、タッチダウン イベントにのみ応答し、タッチアップ インサイド イベントには応答しません。また、タッチダウン イベントでさえ、1 ~ 2 秒間押し続けた後にのみ発生します。
//Create UIButton
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
[button setBackgroundImage:buttonImage forState:UIControlStateNormal];
[button addTarget:self action:@selector(buttonTap) forControlEvents:UIControlEventTouchUpInside];
button.frame = CGRectMake(0, 0, 100, 100);
//Add to UITableViewCell
UITableViewCell *footerCell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"FOOTER_CELL"] autorelease];
[footerCell.contentView addSubview:button];
//Also tried this with just [footerCell addSubview:button];
//Fire Action
- (void)buttonTap {
NSLog(@"Tap");
}
かなり標準的な発行コード。実際、私はこの正確なコードを使用してアプリのいたるところにボタンを作成していますが、テーブル ビューを除いてすべて機能します。細胞の構造について、私が理解していないことがあるに違いありません。