我创建一个UIButton并将它放在UIImageView我放置的上面UIScrollView。我将按钮添加到图像中,如下所示:
backgroundImage.frame = CGRectMake(0, 0, backgroundImage.frame.size.width, mainTextView.frame.origin.y + mainTextView.frame.size.height + bottomMargin + attachBlockHeight);
[self insertSubview:backgroundImage atIndex:0];
UIButton *tmpButton = [[UIButton alloc] initWithFrame:CGRectMake(0, imgGreyLine.frame.origin.y + imgGreyLine.frame.size.height, backgroundImage.frame.size.width, attachBlockHeight)];
[tmpButton addTarget:self action:@selector(btnAttachClicked) forControlEvents:(UIControlEventTouchUpInside)];
//tmpButton.backgroundColor = [UIColor redColor];
[backgroundImage addSubview:tmpButton];
这个按钮在上面iOS6和上面都很好用——它就在那里,它接收触摸事件并完成它必须做的事情。
然而,iOS5我遇到了一个非常奇怪的行为——frame按钮的 保持完全一样,并且按钮清楚地出现在 上view,但是当我向左或向右滑动手指时它只会接收触摸事件。此外,按钮顶部附近没有其他按钮!UIViews
可能是什么原因?我对在这里找到错误感到非常困惑。
编辑:事实证明,滑动也UIButton可以iOS6,但问题是触摸事件也被注册了。