UITableViewCell swipe event

walden systems, objective c, geolocation, ios, CLLocationManager, desiredAccuracy, distanceFilter, startUpdatingLocation, stopUpdatingLocation, delegate, iphone, picture, screen, swipe, iphone, thread, nsthread, uitableviewcell, uitableview, initwithFName, infocellcontroller, nsdate, nsdateformatter nsstring, uuid, time, sleep, uiimage, UIGraphicsBeginImageContext, drawinrect, cgrectmake, nsuserdefaults, standarduserdefaults, setobjectforkey, objectforkey, UIControlEventTouchUpInside, resize picture, merge picture, stringByReplacingOccurrencesOfString, app group, appdelegate, rightSwipeHandle, leftswipehandle
Objective-C defines a small but powerful set of extensions to the ANSI C programming language that enables sophisticated object-oriented programming. Objective-C is the native language for Cocoa programming—it’s the language that the frameworks are written in, and the language that most applications are written in. You can also use some other languages—such as Python and Ruby—to develop programs using the Cocoa frameworks. It’s useful, though, to have at least a basic understanding of Objective-C because Apple’s documentation and code samples are typically written in terms of this language.

There are two things that you need to remember when trying to capture an UITableViewCell swipe event. You need an object that recognizes the event and the method that the object will trigger. In this example, we create two objects, recognizerright and recognizerleft to recognize the left and right swipe events. We also create two methods, rightSwipeHandle and leftSwipeHandle, that will show and set the frame position of the view.

 1 - (void)viewDidLoad
 2 {
 3     UISwipeGestureRecognizer *recognizerright = [
 4                                     [
 5                                      UISwipeGestureRecognizer alloc
 6                                     ] initWithTarget:self action:@selector(rightSwipeHandle:)
 7                                                ];
 8     [recognizerright setDirection:(UISwipeGestureRecognizerDirectionRight)];
 9     [recognizerright setNumberOfTouchesRequired:1];
10     [secondView addGestureRecognizer:recognizerright];
11     [recognizerright release];
12 
13     UISwipeGestureRecognizer *recognizerleft = [
14                                     [
15                                       UISwipeGestureRecognizer alloc
16                                     ] initWithTarget:self action:@selector(leftSwipeHandle:)
17                                                ];
18     [recognizerleft setDirection:(UISwipeGestureRecognizerDirectionLeft)];
19     [recognizerleft setNumberOfTouchesRequired:1];
20     [secondView addGestureRecognizer:recognizerleft];
21     [recognizerleft release];
22     [self.view addSubview:secondView];
23     [super viewDidLoad];
24 }
25 
26 
27 - (void)rightSwipeHandle:(UISwipeGestureRecognizer*)gestureRecognizer
28 {
29     NSLog(@"rightSwipeHandle");
30 
31     [UIView beginAnimations:@"viewanimations" context:nil];
32     [UIView setAnimationDuration:0.8];
33     [UIView setAnimationDelegate:self];
34 
35     secondView.frame=CGRectMake(360, 0, 660, 768);
36     [UIView commitAnimations];
37 }
38 
39 - (void)leftSwipeHandle:(UISwipeGestureRecognizer*)gestureRecognizer
40 {
41     NSLog(@"leftSwipeHandle");
42 
43     [UIView beginAnimations:@"viewanimations" context:nil];
44     [UIView setAnimationDuration:0.8];
45     [UIView setAnimationDelegate:self];
46 
47     secondView.frame=CGRectMake(200, 0, 858, 768);
48     [UIView commitAnimations];
49 }