Zooming code?


Referring to the Kindle version of the book:
The section where zooming is added to the Hypnotizer app.
The code to implement zooming is not shown, was this meant to be a reader challenge ?
Just wondering since the challenges are usually clearly marked.


It is missing?

You should see the following additions to application:didFinishLaunchingWithOptions:

    [scrollView setMinimumZoomScale:0.5];
    [scrollView setMaximumZoomScale:5];
    [scrollView setDelegate:self];

and the addition of this method to the app delegate:

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


Correct. The Kindle version says to add the following code to the app delegate:

[[UIApplication sharedApplication] setStatusBarHidden:YES animated:NO];

And then implement the necessary delegate method:

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

It’s missing the code you’ve added above.


Thanks Guys!


I have added the code above.

I still cannot get the App to zoom.

My viewForZoomingInScrollView method is not being called.

I am using the simulator. Am I correct to get the pinch to crate a zoom I hold down the option key pinch the circles together and then release the option key?

I noticed the following method in the book is depreciated. It probably should read,

[[UIApplication sharedApplication]setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone];


viewForZoomingInScrollView: is an incorrect name: check out the docs for UIScrollViewDelegate and implement the similarly named method from there.