ios - UITableViewCell 中的 UIButton 在 iOS 5x 中没有响应但在 iOS 6 中响应

标签 ios ios5 uitableview uibutton ios6

我有一个按钮,我正在以编程方式添加到 UITableViewCell 中,它的行为非常奇怪。

在 iOS 6 中,它完全按预期工作。在 iOS 5x 中,它只响应 touch-down 事件而不响应 touch-up-inside 事件。甚至在你按住一两秒后才会触发着陆事件。

//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");
}

相当标准的问题代码。事实上,我使用这个确切的代码在我的应用程序中的所有地方制作按钮,它们都可以工作,除了在表格 View 中。关于细胞的结构,一定有一些我不理解的东西。

最佳答案

想通了。很久以前,出于另一个原因,我将 UITapGestureRecognizer 放在了桌面上。它干扰了按钮的功能。多谢你们。 (和女孩)

关于ios - UITableViewCell 中的 UIButton 在 iOS 5x 中没有响应但在 iOS 6 中响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13126447/

相关文章:

ios - instantiateViewControllerWithIdentifier 在哪里使用

iphone - 无法使用 __bridge 将 CFStringRef 转换为 NSString

swift - 如何从 TableView 中删除特定的 coreData 对象

iphone - 调用 reloadData 后阻止更新 header ?

xcode - Swift - 取决于 TableView 单元格的详细 View Controller

ios - 滑入/滑出 subview Controller 在 Swift 的父 View Controller 上部分可见

ios - 使用 Basic Auth 的 AFNetworking 请求最初有效,但几分钟后失败

ios - 启动屏幕 Storyboard

iphone - 使用 NSDate 与时区/DST 无关的时间戳

core-data - 将核心位置的坐标存储在核心数据中。 float 还是 double ?