开发者

Dilemma with buttons within UIScrollView

开发者 https://www.devze.com 2023-01-26 21:54 出处:网络
I\'ve got a UIScrollView (scrollView) and a UIImageView (scrollImage). I\'m trying to add buttons to a scroll view and have them resize and reposition correctly when I zoom in and out. I had the follo

I've got a UIScrollView (scrollView) and a UIImageView (scrollImage). I'm trying to add buttons to a scroll view and have them resize and reposition correctly when I zoom in and out. I had the following code at first to add a button:

[scrollView addSubview:button];

This gave me problems with zooming in and out. The position of the buttons wouldn't stay relative to the image. So i changed it to this:

[scrollImage addSubview:button];

Which made everything zoom 开发者_如何学Pythonin and out nicely, however the buttons have stopped reacting to touches (I assume because they are beneath the UIScrollView).

Is there a way to have both features working correctly?

Thanks Zac


By default a UIImageView has userInteractionEnabled set to NO. Set it to YES and you should be fine.


try by setting like this,

scrollImage.userInteractionEnabled=YES

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号