Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 11-30-2009, 04:34 PM   #1 (permalink)
MMS
Registered Member
 
Join Date: Nov 2009
Location: Connecticut
Posts: 95
Default Image to Scroll with ScrollView- Interface Builder?

Please excuse all the questions all at once today! (And I'm sure I will feel like a fool when I get the answer to this one...)

I am trying to build some simple views containing images (png files) and text. I have been using Interface Builder, adding scrollview to the main view and adding the images and text as subviews... but when I build-and-go only the text view area of the screen can be scrolled.

I have viewed several tutorials about Scrollview, and the only thing I've noticed that's different from what I've been doing differently is that in each of the IB tutorials another view (an unnecessary view that doesn't get used for anything) is created. Why is that? And is it really necessary?

**I am NOT wedded to using Interface Builder. I was hoping to use it because I will have to build several views like this, and I thought it might make it faster. But, if you know of a way to do this programmaticaly, that would also be helpful.

Thank you again!:
MMS is offline   Reply With Quote
Old 11-30-2009, 06:39 PM   #2 (permalink)
Registered Member
 
opetopic's Avatar
 
Join Date: Nov 2009
Location: Brooklyn, NY
Posts: 83
Default

Are you setting the contentSize of your scroll view? You should be doing something like:

Code:
myScrollView.contentSize = CGRectMake(0.0f,100.0f, 320.0f, 100.0f)
where, of course, you should use the dimensions of the content that is being scrolled.
__________________
Opetopic
IsoWords (iTunes)
Twitter @opetopic
opetopic is offline   Reply With Quote
Old 12-01-2009, 12:43 PM   #3 (permalink)
MMS
Registered Member
 
Join Date: Nov 2009
Location: Connecticut
Posts: 95
Default

Quote:
Originally Posted by opetopic View Post
Are you setting the contentSize of your scroll view? You should be doing something like:

Code:
myScrollView.contentSize = CGRectMake(0.0f,100.0f, 320.0f, 100.0f)
where, of course, you should use the dimensions of the content that is being scrolled.


Thank you for your reply here. If I do this programmatically, and I set the contentSize of the scrollview- I would then add the image and text as subviews?
MMS is offline   Reply With Quote
Old 12-02-2009, 01:06 AM   #4 (permalink)
Registered Member
 
opetopic's Avatar
 
Join Date: Nov 2009
Location: Brooklyn, NY
Posts: 83
Default

You can still add your images and other subviews in Interface Builder. However, measure the size of your content in IB and input that information in the line of code I posted before. You can do this by making your IB window really big so that you can see all the content at once and then recording the size of the window.
__________________
Opetopic
IsoWords (iTunes)
Twitter @opetopic
opetopic is offline   Reply With Quote
Old 12-02-2009, 10:07 AM   #5 (permalink)
MMS
Registered Member
 
Join Date: Nov 2009
Location: Connecticut
Posts: 95
Default

Thank you again for your reply. I am still not getting this. Any chance of some step-by-step instruction?
MMS is offline   Reply With Quote
Old 12-02-2009, 12:27 PM   #6 (permalink)
Registered Member
 
opetopic's Avatar
 
Join Date: Nov 2009
Location: Brooklyn, NY
Posts: 83
Default

Add a scroll view to your view in IB. Add all the images/subviews that you want to the scroll view. Now size the scroll view so that it is big enough to contain _all_ of those images/subviews. Hit cmd+3 and note the width and height of the scroll view. Then resize the scroll view to the actual size you want.

Go in your code and use the snippet I posted before in the viewDidLoad method:

Code:
myScrollView.contentSize = CGRectMake(0.0f,100.0f, WIDTH_OF_SCROLLVIEW, HEIGHT_OF_SCROLLVIEW);
try that...
__________________
Opetopic
IsoWords (iTunes)
Twitter @opetopic
opetopic is offline   Reply With Quote
Old 12-03-2009, 10:40 AM   #7 (permalink)
MMS
Registered Member
 
Join Date: Nov 2009
Location: Connecticut
Posts: 95
Default Thank you! Now Working!

Quote:
Originally Posted by opetopic View Post
Add a scroll view to your view in IB. Add all the images/subviews that you want to the scroll view. Now size the scroll view so that it is big enough to contain _all_ of those images/subviews. Hit cmd+3 and note the width and height of the scroll view. Then resize the scroll view to the actual size you want.

Go in your code and use the snippet I posted before in the viewDidLoad method:

Code:
myScrollView.contentSize = CGRectMake(0.0f,100.0f, WIDTH_OF_SCROLLVIEW, HEIGHT_OF_SCROLLVIEW);
try that...
Thank you again! I think I've got this working now.
MMS is offline   Reply With Quote
Reply

Bookmarks

Tags
image, interface builder, scrollviews, text view

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 251
22 members and 229 guests
14DEV, @sandris, ADY, ArtieFufkin10, bookesp, ckgni, dacapo, Dani77, DarkAn, Davey555, Desert Diva, HemiMG, iDifferent, jakerocheleau, JasonR, prchn4christ, Rudy, ryantcb, Speed, theone8one
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,885
Threads: 89,230
Posts: 380,767
Top Poster: BrianSlick (7,129)
Welcome to our newest member, bookesp
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 02:45 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0