hello, how is it possible to add an image to be set inside an uiscrollview using just interface builder and no code. i tried simply adding an image into the scrollview and it didnt work. i know this is a really simple answer however i didnt find any IB related help on achieving this
+2
A:
You can add the image to the scroll view in Interface Builder, but in order for it to scroll (even if the image is larger than the scroll view) you need to manually set the scroll view's contentSize property in code, as I am not aware of any way to set this property in Interface Builder. In your view controller's viewDidLoad method, you can add something like:
scrollView.contentSize = imageView.frame.size;
Only one line of code, shouldn't be too much trouble.
trevorsm
2010-10-13 21:01:45
I would only add that the contentSize need to be bigger than the UIScrollView's frame size as you have it defined in IB. Else, all the content will already be in the visible frame and no scrolling is enabled.
Shiun
2010-10-13 22:17:02
thanks ill use this but i wouldnt to add my scroll view in the header and .m file in order for your line of code to work. ill just try this i though there could be a ib way of doing this automatically thanks :)
Alx
2010-10-14 05:26:17