- Joined
- Sep 14, 2011
- Messages
- 7
- Reaction score
- 0
- Points
- 1
- Location
- Universe 2x/Milky Way/Sol/Earth/USA/NC/Raleigh
- Your Mac's Specs
- MacBookPro (Mac OS 10.6.8, 2.33Ghz Intel Core 2 Duo, 2GB RAM, 320GB Disk)
I'm learning iOS app development using Xcode 3.2.6. I'm having trouble enabling pinch in/out for a view element. My gesture handler isn't getting control and I can't figure out why. It's very frustrating. Here is my code:
What am I doing wrong?
Code:
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
[super viewDidLoad];
CGFloat x=self.view.center.x - (self.view.bounds.size.width/4);
CGFloat y=self.view.center.y - (self.view.bounds.size.height/4);
CGFloat width=self.view.bounds.size.width/2;
CGFloat height=self.view.bounds.size.height/2;
UIView *newView = [[UIView alloc] initWithFrame:CGRectMake(x, y, width, height)];
newView.backgroundColor = [UIColor greenColor];
UITextView *text = [[UITextView alloc] initWithFrame:CGRectMake(0, 30, 100, 30)];
text.text = @"Hello, world";
text.backgroundColor = newView.backgroundColor;
[newView addSubview:text];
UIPinchGestureRecognizer *pinch = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(handlePinch:)];
[newView addGestureRecognizer:pinch];
[pinch release];
[self.view addSubview:newView];
}
- (void) handlePinch:(UIPinchGestureRecognizer*) sender {
NSLog(@"handlePinch in control");
}
What am I doing wrong?