2012-05-04 25 views
2

我正在开发一个通用应用程序,并且里面有一个UIButton,它可以在iPhone上正常工作,但是当我在iPad中单击它时,需要多次点击尝试才能发生触摸事件。iPad:UIButton需要很多攻丝尝试才能捕捉到动作

例如点击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; 
+0

我曾经在处理UISlider的类似问题,结果发现iPad在触摸屏上滑动的区域存在问题。以防万一在另一台iPad上试用您的应用程序。 –

回答

1

你应该检查,以确保您的按钮是正确的大小:

[现金sizeToFit]

我已经经历了,如果一些其他视图阻止它(和你点击那部分按钮不会触发事件),因为您最终按下没有被覆盖的按钮,将需要点击几下。因此,请确保没有其他框架/界限位于按钮的顶部,并确保按钮的大小正确。

0

我同意@Inturbidus这可能是另一个覆盖按钮部分的透明视图。我发现排除故障的最佳方法是更改​​所有其他视图(滚动视图等)的背景颜色,以确保它们的行为与我认为的相同。有时,当你看到背景颜色打开的位置时,它会让你感到惊讶。