UIButton在UIScrollview

时间:2015-07-17 12:58:22

标签: ios objective-c iphone uiscrollview uibutton

我有UIScrollview并查看。如果我在UIScrollview中有UIButton,我认为UIButton无法正常工作。我在两者上启用了用户交互。

enter image description here

按钮我有这个方法:

- (IBAction)search
{
    NSLog(@"SEARCH");
}

enter image description here

无论我给观点的是什么都不起作用。

我解决了这个问题。视图配置不正确(自动布局中的约束)

2 个答案:

答案 0 :(得分:0)

试试这个

- (BOOL)touchesShouldCancelInContentView:(UIView *)view
  {
       return ![view isKindOfClass:[UIButton class]];
  }
希望它有所帮助。

答案 1 :(得分:0)

如果UIButton未向IBAction收件人发送消息,则因为view

中未包含按钮superview.frame

尝试将backgroundColor设置为superview

看看那里:UIButton selector doesn't work in nested UIViews