UIButton in non-visible area of UIScrollView

*爱你&永不变心* 提交于 2019-12-12 06:09:21

问题


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;


来源:https://stackoverflow.com/questions/6011073/uibutton-in-non-visible-area-of-uiscrollview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!