I'll do my best to explain this and hope someone understands. I've searched the Apple developer's forum as well as anything I could find on Google for the last four hours with nothing.
My application has a UIScrollView that houses a UIImageView. I can pinch and zoom in as well as pinch and zoom out. All of those things work perfectly. However, I do have one issue: let's say I zoom in and slide over to a corner or side of the UIImageView. Then I put my fingers down and zoom out. The image obviously gets smaller, but shrinks from all sides (again, obviously) and I end up seeing a gap between the edge of the image and the edge of the screen until I let my fingers go, then it slides back into the 0,0 (x,y) position, which is the top left corner.
I set a background color on the UIScrollView to see what caused that gap and it is, indeed, the UIScrollView. So when zooming out (making the image smaller), the UIScrollView doesn't keep the edge of the image up against the edge of the UIScrollView. Instead, it allows the image to scale down beyond the bounds of the UIScrollView, then just moves the image back into place. But to be more specific, I have the minimum scroll set to 1.0, so the image never gets any smaller than that (and at that minimum, the imageview fills the entire UIScrollView nicely). It's just that the side of the image closest to my fingers isn't "sticky" to the edge of the UIScrollView, and thus a gap is created upon zooming out, albeit temporarily, until I pull my fingers off the screen.
My App Delegate Implementation (AppDelegate.m):
And my App Delegate Header (AppDelegate.h):
Help???
My application has a UIScrollView that houses a UIImageView. I can pinch and zoom in as well as pinch and zoom out. All of those things work perfectly. However, I do have one issue: let's say I zoom in and slide over to a corner or side of the UIImageView. Then I put my fingers down and zoom out. The image obviously gets smaller, but shrinks from all sides (again, obviously) and I end up seeing a gap between the edge of the image and the edge of the screen until I let my fingers go, then it slides back into the 0,0 (x,y) position, which is the top left corner.
I set a background color on the UIScrollView to see what caused that gap and it is, indeed, the UIScrollView. So when zooming out (making the image smaller), the UIScrollView doesn't keep the edge of the image up against the edge of the UIScrollView. Instead, it allows the image to scale down beyond the bounds of the UIScrollView, then just moves the image back into place. But to be more specific, I have the minimum scroll set to 1.0, so the image never gets any smaller than that (and at that minimum, the imageview fills the entire UIScrollView nicely). It's just that the side of the image closest to my fingers isn't "sticky" to the edge of the UIScrollView, and thus a gap is created upon zooming out, albeit temporarily, until I pull my fingers off the screen.
My App Delegate Implementation (AppDelegate.m):
Code:
#import "Bump_AppDelegate.h"
#import "GameViewController.h"
@implementation Bump_AppDelegate
@synthesize window, viewController, gameBoardScrollView, board;
- (void)applicationDidFinishLaunching:(UIApplication *)application {
// load the view controller from the HelloView nib file
GameViewController *vController = [[GameViewController alloc]
initWithNibName:@"GameViewController" bundle:[NSBundle mainBundle]];
// Create a temporary image for the UIScrollView
UIImageView *tempImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"image_to_zoom.png"]];
[self setBoard:tempImageView];
[tempImageView release];
gameBoardScrollView.maximumZoomScale = 2.5;
gameBoardScrollView.minimumZoomScale = 1.0;
gameBoardScrollView.clipsToBounds = YES;
gameBoardScrollView.alwaysBounceVertical = NO;
gameBoardScrollView.alwaysBounceHorizontal = NO;
gameBoardScrollView.bounces = NO;
gameBoardScrollView.bouncesZoom = NO;
gameBoardScrollView.showsVerticalScrollIndicator = NO;
gameBoardScrollView.showsHorizontalScrollIndicator = NO;
gameBoardScrollView.pagingEnabled = NO;
gameBoardScrollView.delegate = self;
// set the view
self.viewController = vController;
// release the view controller
[vController release];
// Override point for customization after application launch
[window addSubview:[viewController view]];
[gameBoardScrollView addSubview:board];
[window addSubview:gameBoardScrollView];
[window makeKeyAndVisible];
}
And my App Delegate Header (AppDelegate.h):
Code:
#import <UIKit/UIKit.h>
#import "GameViewController.h"
@class GameViewController;
@interface Bump_AppDelegate : NSObject <UIApplicationDelegate, UIScrollViewDelegate> {
IBOutlet UIWindow *window;
IBOutlet GameViewController *viewController;
IBOutlet UIScrollView *gameBoardScrollView;
// Game board
UIImageView *board;
}
@property (nonatomic, retain) UIWindow *window;
@property (nonatomic, retain) GameViewController *viewController;
@property (nonatomic, retain) UIScrollView *gameBoardScrollView;
@property (nonatomic, retain) UIImageView *board;
@end
Help???