Monday, April 7, 2014

Autolayout and UIScrollView

Just a quick update on a small problem I uncovered. I was working on OttoJotts last night trying to get Beta 1.1 out the door (I did eventually get it out, although it was Beta 1.11) when I stumbled on a problem with the UIScrollView I'm using for the help file. When I created the first Beta 1.0 I ran into an issue with the buttons not working on 4 inch screens (I originally wrote the app for iPhone 3G to give you an idea of how long this has been). I went through all of my xib's in Interface Builder and updated them to use auto layout and - ta da! - everything worked. Except for help.
My help screen has two elements - a UIButton to close the help screen and a UIScrollView to view the incredibly long png I created for the help (it's over 2k pixels in length). When using auto layout with a UIScrollView, the scroll view interprets the setting meaning a slightly different experience than what you'd expect. When I turned off auto layout, the scroll view worked perfectly well and I was able to view all of the help text correctly - with one exception: the UIScrollView was now positioned at the bottom of the interface rather than directly under the button.
I still have some things to work out with the 3.5" and 4" screens so I'm holding off on fixing that until a later date. Still, it's something to keep in mind - UIScrollView and auto layout are not good buddies.