iphone - iPad : UIButton requires many tap attempts to caught action

标签 iphone objective-c ios ipad ios-universal-app

我正在开发一个通用应用程序,其中有一个 UIButton,它可以在 iPhone 上正常工作,但是当我在 iPad 上单击它时,需要多次单击尝试才能触发触摸事件。

例如5-6 次点击后,它会执行点击事件。

下面是 UIButton 代码。请帮忙。

UIView *footer = [[[UIView alloc] initWithFrame:(CGRectMake(0, 0, self.tableView.frame.size.width, 54))] autorelease];
float buttonWidth = (int)((self.tableView.frame.size.width - 12 - 12) / 3);
float buttonHeight = 44;

if (clientState.Devicetype == 1) // 1=Ipad
    buttonHeight = 90;
cash = [[UIButton buttonWithType:UIButtonTypeRoundedRect] retain];

cash.frame = CGRectMake(6, 10, buttonWidth, buttonHeight); 
[cash setTitle:@"Cash" forState:UIControlStateNormal];
[cash setTitleColor:[UIColor lightGrayColor] forState:UIControlStateDisabled];
[cash addTarget:self action:@selector(handleCash:) forControlEvents:UIControlEventTouchUpInside];
cash.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleRightMargin;

if (clientState.Devicetype == 1) // 1=Ipad
{
    cash.titleLabel.font = [UIFont systemFontOfSize:28];    
}

[footer addSubview:cash];

self.tableView.tableFooterView = footer;

最佳答案

您应该检查以确保您的按钮尺寸正确:

[现金大小]

我有过这样的经历,如果其他 View 阻止了它(并且您单击了按钮的那部分,它不会触发该事件),则需要多次单击,因为您最终按下了未被覆盖的按钮.因此,请确保按钮顶部没有其他框架/边界,并确保按钮的大小正确。

关于iphone - iPad : UIButton requires many tap attempts to caught action,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10451289/

相关文章:

iphone - NSOperation 和 EXC_BAD_ACCESS

ios - 枚举 XML 提要中的项目

objective-c - 将对象添加到可变数组时出现奇怪的 "mutating method sent to immutable object"错误

iphone - 以编程方式创建 Iphone 应用程序与 Storyboard

iphone - IOS如何用非数字调用电话

objective-c - Block_copy 是递归的吗?

ios - ALAsset GPS 元数据与 exif GPS 数据不匹配

ios - 为什么我的约束设置对 X/Height 不满意?

iphone - 如何在 Windows 上运行 iPhone 开发工具?有可能吗?

iphone - 将 C++ API 转换为托管代码 API