UIButtons over a UIImageView Zooming

落花浮王杯 提交于 2019-12-06 02:10:23

This might not help and it is not what it appears that you want to do.

However, when I want buttons associated with a scrollview, I add a parent view, add the buttons to that view and also add the scrollview to that view. The button(s) and the scrollview would be siblings. This allows the user to scroll around the contents of the scrollview, while insuring that the buttons are always in view.

-isdi-

By default, UIImageView has userInteraction disabled. Have you changed this?

Also, I would be really uneasy adding subviews to an UIImageView, it's really meant to hold one image. It would be better to create a normal UIView and add the UIButtons and UIImageView to that. It's very easy to control the ordering so that the buttons appears on top of the image.

P.S. Just to make your life easier, instead of :

[scrollView2 setContentSize:CGSizeMake(scroll2ImageView.frame.size.width, scroll2ImageView.frame.size.height)];

You can use :

[scrollView2 setContentSize:scroll2ImageView.frame.size];

Make a single view to contain all your zoomable content (everything it would appear), and call it say contentView. Now place everything you want in that contentView, the imageView and all your buttons etc.

In your UIScrollView delegate place this: (Be sure to set the scrollView's delegate if you haven't already)

- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView {
    return self.contentView;
}

Only one view is allowed to zoom, but that one view can however contain other views that will scale because they're child views.

Also be sure to set the scrollView's contentSize value to the exact size of your zoomable contentView.

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