UIScrollView - scrollRectToVisible - showing a button at the center of the screen?

1.3k Views Asked by At

I have a uiscrollview with tons of buttons in it. What I need to do is show one of these buttons at the center of the screen.

When I use scrollRectToVisible (passing the button-frame), the scrollview indeed shows the button - but sometimes at the top-left corner, sometimes at the bottom right corner - apparently depending on when the button hits the visible area of the scrollview.

But - as mentionend - I need the button to appear in the center of the screen.

Any hints on how to achieve that?

Thanks for any help!

1

There are 1 best solutions below

1
On

You could pass a rect with the size of your scroll view's visible area, centered around the button's center.