Fix UIButton on top of UIScrollView

I am trying to figure out how to overlay a UIButton on top of a UIScrollView. Basically, the user could use scrolling as usual. But the button in the upper right corner of the scroll will remain in a fixed position. Any thoughts?

+5
source share
3 answers

Do not add UIButton as a subspecies UIScrollView, but instead of "self.view"

Your hierarchy should look like this.  Notice how the button is now in the drop down for the scroll view.  Just drag the button out

+3
source

A list of hierarchy elements will appear in InterfaceBuilder, which you will place in your view, drag a button from the view belonging to scrollView to the view containing the subview.

Your view hierarchy will look like this

mainView

|

----Button

|

----ScrollView

Instead

mainView

|

----ScrollView

  |

  ----Button

, , ScrollView mainView. scrollView mainView, UIView scrollView UIButton UIScrollView

+3

IB "" . . "self.view" - .

, , . "subview" "parent". , .

When you feel comfortable, you should put the button in "self.view", and not as a scroll routine. In addition, if you want it to appear in TOP (physical level "Z"), you need it to be below the scroll in the list. (this indicates a subtle issue with the CStreet solution)

+1
source

All Articles