Note that there are some explanatory texts on larger screens.

plurals
  1. POSwipe gestures in Multiview App
    primarykey
    data
    text
    <p>I am quite new to iOS development and trying hard to develop an App. I am unable to use swipe gestures in a multiview app. I am pasting the code, can you guys please point out the error. It's a view based application.</p> <p>Here is mainViewController.h</p> <pre><code> #import &lt;UIKit/UIKit.h&gt; @interface mainViewController : UIViewController &lt;UITableViewDelegate,UITableViewDataSource&gt; { NSArray *listData; } @property (nonatomic, retain) NSArray *listData; @end </code></pre> <p>Now mainViewController.m</p> <pre><code>#import "mainViewController.h" @implementation mainViewController @synthesize listData; - (void)viewDidLoad { NSArray *array =[[NSArray alloc] initWithObjects:@"Apple",@"Boy",@"Cat", nil]; self.listData = array; [array release]; [super viewDidLoad]; } - (void)dealloc { [listData release]; [super dealloc]; } #pragma mark - View lifecycle - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return [self.listData count]; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *SimpleTableIdentifier = @"SimpleTableIdentifier"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier: SimpleTableIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:SimpleTableIdentifier] autorelease]; } NSUInteger row = [indexPath row]; cell.textLabel.text = [listData objectAtIndex:row]; //cell.textLabel.font = [UIFont boldSystemFontOfSize:50]; return cell; } - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath { NSUInteger row = [indexPath row]; NSString *rowValue = [listData objectAtIndex:row]; if([rowValue isEqualToString:@"Apple"]) { cell.backgroundColor = [UIColor redColor]; } else if([rowValue isEqualToString:@"Boy"]) cell.backgroundColor= [UIColor yellowColor]; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { NSUInteger row = [indexPath row]; NSString *rowValue = [listData objectAtIndex:row]; if([rowValue isEqualToString:@"Apple"]) { mainViewController* flashView=[[mainViewController alloc] initWithNibName:@"fl" bundle:[NSBundle mainBundle]]; [self.view addSubview:flashView.view]; } //[tableView deselectRowAtIndexPath:indexPath animated:YES]; } - (void)viewDidUnload { [super viewDidUnload]; self.listData=nil; // Release any retained subviews of the main view. // e.g. self.myOutlet = nil; } - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { return 110; } @end </code></pre> <p>I have added an UIViewSubController class with the xib file named "fl".</p> <p>In fl.h:</p> <pre><code>#define kMinimumLength 5 #define kMaxVariance 1 #import &lt;UIKit/UIKit.h&gt; #import "mainViewController.h" @protocol flDelegate; @interface fl : UIViewController &lt;UIGestureRecognizerDelegate&gt; { CGPoint gestureStartPoint; id &lt;flDelegate&gt; delegate; } @property CGPoint gestureStartPoint; @property (nonatomic,retain) id &lt;flDelegate&gt; delegate; @end @protocol flDelegate -(IBAction)flDidFinish:(fl *)controller; @end </code></pre> <p>And now in fl.m:</p> <pre><code>#import "fl.h" @implementation fl @synthesize delegate; @synthesize gestureStartPoint; - (void)dealloc { [super dealloc]; } #pragma mark - View lifecycle -(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch =[touches anyObject]; gestureStartPoint =[touch locationInView:self.view]; } -(void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch =[touches anyObject]; CGPoint CurrentPosition =[touch locationInView:self.view]; if(CurrentPosition.x &gt;= kMinimumLength) { NSLog(@"Go"); } } - (void)viewDidUnload { [super viewDidUnload]; // Release any retained subviews of the main view. // e.g. self.myOutlet = nil; } </code></pre> <p>Here everything is working, but it is not detecting swipes, and not printing Go.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload