2
votes

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

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

- (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 though.

Any help is appreciated! Thanks


Like i thought before I added this piece of 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!


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.

1

1 Answers

0
votes

Good Day, I realize very late to the game, but wanted to updated what i found on this, should anyone else come across this issue.

All did was set BOTH the UIImageView and the UIScrollView to "Aspect Fit" and this fixed the issue for me. This may be an Xcode 7 feature, but it works.