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

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

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

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.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-19-2011, 11:09 PM   #1 (permalink)
Registered Member
 
Join Date: Jul 2011
Location: Montreal, Canada
Posts: 104
esoteric is on a distinguished road
Default UIScrollView - Zooming problems

So a little explanations of what my view is doing before the problem, the page loads a bunch of buttons that are clickable into the contentView which is a subView of my scrollView.

i got a UIViewController, inside i have my
UIScrollView scrollView to handle the scrolling and zooming
UIView contentView which i add all the UIButtons to.

Alright i'll try to only put the code which i believe might need to be changed.

in viewDidLoad
Code:
scrollView.contentSize = CGSizeMake(320, (20+totalRows*OFFSET_Y) );
[scrollView setMaximumZoomScale:4];
[scrollView setMinimumZoomScale:1];
[scrollView setDelegate:self];

[contentView setFrame:CGRectMake(0, 0, 320, (20+totalRows*OFFSET_Y) )];

[self.scrollView addSubview:contentView];
Doing some calculation to see how big i need to content size to be to fit all the buttons, then i add the contentView as subView to my scrollView.
I then add all the UIButtons as subview of my contentView

Code:
- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView
{
    return [self contentView];
}
Got my delegate method for zooming returning the contentView.

Ok so everything is scrollable and zoomable like it should be..all my UIButtons are still clickable and works how it should be.

The problem is after i zoom in/out when i scroll all the way to the bottom of my scrollView it's being cut off from the bottom, so the last row of buttons are being cut in half. even when i rezoom to 1:1 it's still cut off.

I've got a NavigationController in the app which is 44 pixels, not sure if that's screwing something up somehow.

I was checking the contentSize of the scrollView and contentView and before any zooming is done, the Height of my scrollView is 44 pixels bigger than the contentView, but after any zooming the ratio is 1:1 and that seems to be the problem.
I'm not changing the size anywhere in the code.

Any help is appreciated!
Thanks

EDIT:
I've thought about keeping track of the zoom scale then adding 44pixels * zoom scale to the scrollView's contentView height in
- (UIView *)viewForZoomingInScrollViewUIScrollView *)scrollView method but this doesn't seem right.
esoteric is offline   Reply With Quote
Old 11-23-2011, 02:06 AM   #2 (permalink)
Registered Member
 
Join Date: Jul 2011
Location: Montreal, Canada
Posts: 104
esoteric is on a distinguished road
Default

Like i thought before I added this piece of code

Code:
- (void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(UIView *)view atScale:(float)scale
{    
    self.scrollView.contentSize = CGSizeMake(self.scrollView.contentSize.width, self.scrollView.contentSize.height + (44 * scale));
}
And now Zooming doesn't cut anything off and seems to be working correctly.

I still don't believe this is what I should have to do but I guess it works for now.

Still hoping someone has a better answer!
esoteric is offline   Reply With Quote
Old 11-26-2011, 10:28 PM   #3 (permalink)
Registered Member
 
Join Date: Jul 2011
Location: Montreal, Canada
Posts: 104
esoteric is on a distinguished road
Default

After playing more with my app I realized that the zooming was never the problem to begin with. The actual problem was with my UIView *contentView. After changing the background colour of my scrollView and my contentView (to 2 very diff colours) I noticed that my contentView wasn't long enough to cover all of the buttons.

So at first load the scrollView was big enough to see everything but once you zoom and it takes the size of the contentView it wasn't being adjusted properly!

All that to say, it finally works how it should!..haha no replies but hopefully someone might find this useful! Best tip was to change the background colours.
esoteric is offline   Reply With Quote
Reply

Bookmarks

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: 380
18 members and 362 guests
7twenty7, Alex-alex, Apptronics RBC, baja_yu, chiataytuday, Clouds, dedeys78, dre, Duncan C, e2applets, ipodphone, jeroenkeij, leostc, matador1978, mbadegree, QuantumDoja, Retouchable, usernametaken
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,676
Threads: 94,125
Posts: 402,910
Top Poster: BrianSlick (7,990)
Welcome to our newest member, jleannex55
Powered by vBadvanced CMPS v3.1.0

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