I have a UIScrollView with an UIImageView as the content. It displays fine, and scrolls fine. No problems there. The image is considerably wider than the screen, so I want to be able to “auto center” a specific portion (coordinates) of the image within the scrollview.
Here is where I’m stuck, though. The desired centering location will dynamically change based on the use of the application, so I need to be able to configure it so that a desired coordinate of the image view (x,y) is centered automatically within the scrollview when loaded. It doesn’t have to autoscroll/animate, it just needs to be there.
I’ve seen similar questions/answers for centering content when gestures/zooming are being used, but neither are employed here. Just scrolling. I just need to be able to have a set portion of the image be centered within the scrollview when it first loads.
I hope I’ve made sense. Thanks for your time.
I’m on an iPhone right now, so excuse me if this code is a little funky, as I can’t remember exactly if the center property is available without calling size.center first…