Can't zoom - fault mine or iOS simulator's?


I carefully followed the instructions in ch. 6 under “Zooming”, and get no warnings or errors, but I am unable to zoom in the iOS simulator. The little “finger points” appear and move around, but don’t cause any zooming to happen. Any ideas?


Perhaps not that intuitive - you still need to (left) click too :slight_smile:


I did click with the mouse and moved it around while holding the “Alt” key, but no zooming.


OK, didn’t think it would be that obvious :wink:

Post your listing? Probably just missed something – easily done with this chapter as it goes from panning to zooming by changing the code you just added. There’s an added instance variable too that points to the view for zooming.


In HypnosisterAppDelegate.h I have:

@interface HypnosisterAppDelegate : UIResponder <UIApplicationDelegate, UIScrollViewDelegate> { HypnosisView *view; }

In HypnosisterAppDelegate.m I have:

[code]#import “HypnosisterAppDelegate.h”
#import “HypnosisView.h”

@implementation HypnosisterAppDelegate

  • (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.

    [[UIApplication sharedApplication] setStatusBarHidden:YES

    CGRect screenRect = [[self window] bounds];
    UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:screenRect];

    [scrollView setMinimumZoomScale:1.0];
    [scrollView setMaximumZoomScale:5.0];
    [scrollView setDelegate:self];

    [[self window] addSubview:scrollView];

    CGRect bigRect = screenRect;
    view = [[HypnosisView alloc] initWithFrame:screenRect];
    [scrollView addSubview:view];

    [scrollView setContentSize:bigRect.size];

    BOOL success = [view becomeFirstResponder];
    if (success)
    NSLog(@“HypnosisView became the first responder”);
    NSLog(@“Could not become first responder”);

    self.window.backgroundColor = [UIColor whiteColor];
    [self.window makeKeyAndVisible];
    return YES;

  • (UIView *)viewforZoomingInScrollView:(UIScrollView *)scrollView
    return view;


...has a typo :slight_smile:  The 'f' in 'for' is lowercase, doesn't match the delegate method.  Change it to 'For' and it works.

…has a typo :slight_smile: The ‘f’ in ‘for’ is lowercase, doesn’t match the delegate method. Change it to ‘For’ and it works.


You’re right, that does work. :slight_smile: It’d be kind of nice if that sort of thing generated a warning, but of course you can name a new method what you want to. o_O

Thanks for your help!