A few opinions.
1. In the handleSwipeEvent: method it makes more sense to me to make CGPoint location the [self.imageView center] as the starting point rather than the [recognizer locationInView:self], unless the recognizer is within the bounds of the imageView. It is rather strange, when the swipe is initiated outside of the image, for the image to jump first to the touch point and then slide.
2. In handleRotateEvent I think it is useful to add
Code:
if ([recognizer state] == UIGestureRecognizerStateEnded)
before the animation block. This allows the rotated position to remain until the touch is released. As written, if the rotation pauses the image begins to fall back to its initial state. Then if the rotation resumes it jumps back to the previous rotation, and continues rotating. Also, without this call my attempts to rewrite the animation block with [UIView animateWithDurationâ¦] produced very bizarre results.
For those interested in how this method is redone using blocks, this is what I did
Code:
-(void)handleRotateEvent:(UIRotationGestureRecognizer *)recognizer
{
[self updateDisplayValuesWithPhase:@"handleRotateEvent" tapCount:1 touchCount:2];
CGPoint location = [recognizer locationInView:self];
[self.imageView setTransform:CGAffineTransformMakeRotation([recognizer rotation])];
[self.imageView setCenter:location];
if ([recognizer state] == UIGestureRecognizerStateEnded)
{
/*
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:.5];
[self.imageView setTransform:CGAffineTransformIdentity];
[UIView commitAnimations];
*/
[UIView animateWithDuration:.5 animations:^{[self.imageView setTransform:CGAffineTransformIdentity];}];
}
}
Two minor points:
1. on p. 185 and 196 in the loadShake method The NSLog should be
Code:
NSLog(@"Error %ld loading sound at path: %@", error, path);
since using just
%d generates a warning
2. A couple of methods only appear in the complete listing. -(void)resetImageInView, -(BOOL)shouldAutoRotate⦠and -(void)dealloc, not as separate entries, so when the text states the the .m is now complete, be sure to consult the full listing and include these methods.
Lastly a question. Sometimes in the [UIView beginAnimations:context:] sometimes nil is used and sometimes NULL. They are essentially the same, correct? and interchangeable. (My internet research brought up some issues about nil - Objective C object and NIL Objective C class and NULL all others.) Does it really matter?
Bob