p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   BOOK: Beginning iOS 4 Application Development (http://p2p.wrox.com/forumdisplay.php?f=599)
-   -   Chapter 14 - Long Press (http://p2p.wrox.com/showthread.php?t=85685)

ggrngg November 14th, 2011 10:18 PM

Chapter 14 - Long Press
While testing out the example I found that I needed to tap the buttons twice. Thought it was something I did until I tested the sample code from the chapter and it did the same thing. After doing some research (for several hours) I found the solution. Modify the handleLongpressGesture and wrap it in the if (sender.state == UIGestureRecognizerStateBegan) block. Evidently since it is a "continuous gesture" it must be checked to see if the state began. Once I did that - viola - it worked perfectly. Just thought I'd post since it might help someone else out.


//handle Long Press Gestures
-(IBAction)handleLongpressGesture:(UIGestureRecognizer *) sender {
    if (sender.state == UIGestureRecognizerStateBegan) {
        UIActionSheet *actionSheet=[[UIActionSheet alloc]
                        otherButtonTitles: @"Save Image",nil];
        [actionSheet showInView:self.view];       
        [actionSheet release];

All times are GMT -4. The time now is 02:47 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.