Can't zoom in


I typed all the codes in the book, and there is no warning or error when compling, however i can’t zoom on the IOS simulator.

here is the code in the appdelegate.m

[code]#import “WhereamiAppDelegate.h”
#import “hypnosisView.h”

@implementation WhereamiAppDelegate

@synthesize managedObjectContext = _managedObjectContext;
@synthesize managedObjectModel = _managedObjectModel;
@synthesize persistentStoreCoordinator = _persistentStoreCoordinator;

  • (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide];
    // Override point for customization after application launch.
    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];
    self.window.backgroundColor = [UIColor whiteColor];
    [self.window makeKeyAndVisible];
    BOOL success = [view becomeFirstResponder];
    if (success) {
    NSLog(@“made it”);
    return YES;

-(UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView{
return view;

code in appdelegate.h

@interface WhereamiAppDelegate : UIResponder <UIApplicationDelegate,UIScrollViewDelegate> { hypnosisView *view; }
can anybody help me to figure out the problem? :blush:


How are you zooming in on the iOS simulator?

You need to press option + clicking on screen and moving the mouse.

Looking at the code - it looks fine and would compile without errors.


I also have this outcome on my iPhone simulator; the same code zooms correctly when tested on my actual iPhone.

(This is the iPhone 6.1 simulator, using the option-drag technique. It correctly shows the pinch-simulation dots, but takes no action when I pinch. Actual pinching on a real iPhone zooms correctly.)

  • bobmcd


It’s because of messing the order.

You can try the code like this :

self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; // Override point for customization after application launch. self.window.backgroundColor = [UIColor whiteColor]; [self.window makeKeyAndVisible];

Hope it works !


I had this problem too.
Turns out u need to press options and then “click” on the simulator, which is three fingers (instead of one) on my trackpad.