UIButton in non-visible area of UIScrollView

2019-08-30 23:16发布

问题:

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:

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;