UIButton in non-visible area of UIScrollView

2019-08-30 23:37发布

How can I get a button tap for a button which is located in a UIScrollView, but in its initially non-visible area?

Solved
Problem was that the content was visible within a non-clipped view - therefore not getting touches.

1条回答
等我变得足够好
2楼-- · 2019-08-30 23:58

I think you should add an action (yourAction in the code below) to the UIButton.

programmatically:

[button addTarget:self action:@selector(yourAction:) forControlEvents:UIControlEventTouchUpInside];


-(void)yourAction:(id)sender{
    // your code
}

With the gui builder you should connect your UIButton to an action defined as IBAction in your .h controller file:

-(IBAction)yourAction:(id)sender;
查看更多
登录 后发表回答