Dan*_*eek 1 uibutton uitableview ios ios5 ios6
我有一个按钮,我正在以编程方式添加到UITableViewCell中,它表现得非常奇怪.
在iOS 6中,它完全按预期工作.在iOS 5x中,它仅响应触摸事件而不是触摸内部事件.甚至触地事件也只会在您按住一两秒后触发.
//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");
}
Run Code Online (Sandbox Code Playgroud)
非常标准的问题代码.事实上,我使用这个确切的代码在我的应用程序中的所有位置制作按钮,除了在表格视图中它们都可以工作.必须有一些我不了解细胞结构的东西.
| 归档时间: |
|
| 查看次数: |
774 次 |
| 最近记录: |