I do not get the zoom to work


#1

At page 139 to 141 there are some changes to make for the zooming. I have entered/changed the code but can not get it to work. Please can someone here see if they can spot any error in my code.

The shake part works, so the code for first responder is correct.
I placed a breakpoint in the HypnosisterAppDelegate.m, viewForZoomingInScrollView. But my code never reached that part when executed.

I just post some of the code to save space.

HypnosisterAppDelegate.h

[code]#import <UIKit/UIKit.h>

#import “HypnosisView.h”

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

@property (strong, nonatomic) UIWindow *window;

@end
[/code]

HypnosisterAppDelegate.m

[code]@synthesize window = _window;

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

    CGRect screenRect = [[self window] bounds];

    UIScrollView *scrollView =[[UIScrollView alloc] initWithFrame:screenRect];
    view = [[HypnosisView alloc] initWithFrame:screenRect];

    [scrollView setMinimumZoomScale:1.0];
    [scrollView setMaximumZoomScale:5.0];
    [scrollView setContentSize:screenRect.size];

    [[self window] addSubview:scrollView];
    [scrollView addSubview:view];

    [scrollView setDelegate:self];

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

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

  • (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView
    {
    return view;
    }
    [/code]


#2

:open_mouth:
Ok, found the problem. No error in the code.
I missunderstood how to zoom in the simulator. I pressed ALT and moved the two “fingers” using the touch pad. But I never pressed the mouse button.

Sorry :unamused: