Go Back   MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old May 11, 2011, 02:51 AM   #1
newlearner
macrumors member
 
Join Date: Jul 2009
Location: india
problems in implementing Gesture Recognizers for iPad app

hello,

i am working with gesture recognizers in my app. The app crashes whenever there is any gesture - tap or swipe. here is my code for detecting tap:

Code:
-(void)viewDidLoad{
    UITapGestureRecognizer *recognizer;

    recognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapHandler:)];
    recognizer.numberOfTapsRequired=1;

    recognizer.numberOfTouchesRequired=1;
    [self.view addGestureRecognizer:recognizer];
    [recognizer release];
   [super viewDidLoad];
}

- (void) tapHandler: (UITapGestureRecognizer *)gesture {
    NSLog(@"Tap ...");
}
The app being written is for iPad using iOS 4.3.2

can anyone point out where the problem is...

many thanks
newlearner is offline   0 Reply With Quote
Old May 11, 2011, 03:16 AM   #2
jnoxx
macrumors 65816
 
jnoxx's Avatar
 
Join Date: Dec 2010
Location: Aartselaar // Antwerp // Belgium
not sure, haven't been working with recognizers alot. but u are releasing it, before you're using it. try commenting out the release, and check it out.
jnoxx is offline   0 Reply With Quote
Old May 11, 2011, 03:44 AM   #3
newlearner
Thread Starter
macrumors member
 
Join Date: Jul 2009
Location: india
@ jnoxx : tried that too...but it doesnt make any difference
newlearner is offline   0 Reply With Quote
Old May 17, 2011, 07:35 PM   #4
Alphaforcex
macrumors member
 
Join Date: Jun 2010
This is what I did and it works. What's the error?

Code:
        
//Swipe
        UISwipeGestureRecognizer *swipeLeft = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeFrom:)];
        swipeLeft.direction = UISwipeGestureRecognizerDirectionLeft;
        [self.view addGestureRecognizer:swipeLeft];
        [swipeLeft release];

//Tap 
	UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleSingleTap:)];
 	[self.view addGestureRecognizer:singleTap]; 
        [singleTap release];
Alphaforcex is offline   0 Reply With Quote
Old May 17, 2011, 10:20 PM   #5
Sykte
macrumors regular
 
Join Date: Aug 2010
Quote:
Originally Posted by jnoxx View Post
not sure, haven't been working with recognizers alot. but u are releasing it, before you're using it. try commenting out the release, and check it out.
Actually he isn't, sorry typing on the iPad otherwise I would explain why. You should post any errors you receive this will help other developers help you.
__________________
Looking for apple/tech news on your IPhone or IPod touch, Try out PowerFeed. 100% free.
Sykte is offline   0 Reply With Quote
Old May 17, 2011, 10:55 PM   #6
PhoneyDeveloper
macrumors 68030
 
PhoneyDeveloper's Avatar
 
Join Date: Sep 2008
@OP, what does crash mean? What do you see in the debugger console?
PhoneyDeveloper is offline   0 Reply With Quote
Old May 17, 2011, 11:51 PM   #7
newlearner
Thread Starter
macrumors member
 
Join Date: Jul 2009
Location: india
@Alphaforcex: Your code doesnt work for me though. On which OS version are you implementing it?

@PhoneyDeveloper: The program simply hangs up with an objc_msgSend error. Please find attached the screenshot of the stack trace
Attached Thumbnails
Click image for larger version

Name:	errortrace.png
Views:	24
Size:	112.8 KB
ID:	285766  
newlearner is offline   0 Reply With Quote
Old May 18, 2011, 07:18 AM   #8
PhoneyDeveloper
macrumors 68030
 
PhoneyDeveloper's Avatar
 
Join Date: Sep 2008
Crashes in objc_MsgSend are caused by sending a message to a dealloced object. I can't tell why that would happen in your case. The object being messaged is presumably your view controller. Is it possible that the view outlives the view controller? You can turn on NSZombies to debug this further. And you can search the forum and google for objc_MsgSend. It's a very common problem.

You can start here

http://www.sealiesoftware.com/blog/a...c_msgSend.html
PhoneyDeveloper is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Tags
ipad, uigesturerecognizer

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Implementing Google AdMob to UIWebview app nightwalker21 iPhone/iPad Programming 5 May 19, 2014 03:11 PM
Apple Implementing Changes to App Store Rankings to Promote Better App Discovery MacRumors MacRumors.com News Discussion 70 Sep 3, 2013 10:06 AM
Resolved: UITextView and Event Handling/Gesture recognizers brontosaurus iPhone/iPad Programming 2 Mar 28, 2013 01:24 AM
Touchpad Gesture Problems 2Turbo OS X 10.8 Mountain Lion 0 Aug 19, 2012 10:03 PM
Gesture Problems drummerdude1390 OS X 10.8 Mountain Lion 4 Aug 2, 2012 12:54 PM

Forum Jump

All times are GMT -5. The time now is 08:20 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC