My UIPinchGestureRecognizer isn't working!

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. :Grimmace: Here is my code:

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?
 

BrianLachoreVPI


Retired Staff
Joined
Feb 24, 2011
Messages
3,733
Reaction score
124
Points
63
Location
Maryland
Your Mac's Specs
March 2011 15" MBP 2.3GHz i7 Quad Core 8GB Ram | Mid 2011 27" iMac 3.4 GHz i7 16 GB RAM 2 TB HDD
Moved to the proper forum.
 
OP
M
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)
Sorry, I didn't see that forum. I'm a newbie.
 
OP
M
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)
There's hope!!

I'm not sure why but when I was shutting down Xcode, it seemed as though there was a file that wasn't saved that I wasn't expecting. So after I saved it and reopened the project, I was able to get my pinch recognizer method get control!! That's a major step for me!! I think I'm on my way! :D
 
Joined
Aug 21, 2011
Messages
36
Reaction score
0
Points
6
Your Mac's Specs
Late 2010 MacBook Pro 13 Inch
Glad you solved it! :D Useful to remember should someone decide to take up iOS development!
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top