Using xCode 4.3.2, I have the following code in initWithFrame in my view.m:
UIPinchGestureRecognizer *recognizer = [[UIPinchGestureRecognizer alloc]
initWithTarget: self action: @selector(pinch:)
];
oldScale = recognizer.scale;
[self pinch: recognizer];
[self addGestureRecognizer: recognizer];
// code to create label is also in here, works. label displays no problem
[self addSubview: label];
my pinch method is as follows:
- (void) pinch: (UIPinchGestureRecognizer *) recognizer
{
NSLog(@"pinch:");
label.bounds = CGRectMake(
(self.bounds.size.width - width * recognizer.scale) / 2,
(self.bounds.size.height - height * recognizer.scale) / 2,
width * recognizer.scale,
height * recognizer.scale
);
label.font = [UIFont systemFontOfSize: 20 * recognizer.scale];
NSString *verdict;
if (recognizer.scale > oldScale) {
verdict = @"spread";
} else if (recognizer.scale < oldScale) {
verdict = @"pinch";
} else {
verdict = @"neither";
}
oldScale = recognizer.scale;
label.text = [NSString stringWithFormat: @"%@ %g",
verdict, recognizer.scale
];
}
because i actually call pinch in my initWithFrame method, it runs once, but when i perform a pinch in the iphone simulator, it doesn't register at all. is there some setting in xcode 4.3.2 i don't know about? this code works everywhere else i've tried running it - but those versions of xcode are all 4.3.