Hi all..
Here I am yet again with yet another problem.
I wanted to create a UIView to deal with all my input (swipes. shake) needs
but I create and add the view from a the main myAppDelegate window
I can get shakes to work.
but gestures are a no go.
Zero error but I did have to trigger ViewDidAppear manually (I did try viewDidAppear nothing triggered) from Delegate.
long and short of the question:
Will gestures only work in a NSViewcontroller ?
or is there another way to get gestures to work in a UIView?
One thing might be I have a layer of buttons on the window (which is on top of the view) but don't start the swipe on any of them when I'm testing it.
*** Ok thinking (as I wrote) about this I add the UISwipeGestureRecognizer to the window and it worked !! I guess because it was the top layer.
But one thing comes to mind .. should I rejig my code to put all the buttons and shake on separate views working under a view controller and put next to nothing in the window myAppDelegate.. ??? is that better form?
thanks fir your help
Ian
Here I am yet again with yet another problem.
I wanted to create a UIView to deal with all my input (swipes. shake) needs
but I create and add the view from a the main myAppDelegate window
Code:
[[self window] addSubview:myNewView];
I can get shakes to work.
Code:
- (BOOL)canBecomeFirstResponder {
return YES;
}
- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event {
if ( event.subtype == UIEventSubtypeMotionShake ) {
NSLog(@"Shake!");
functionText =(NSMutableString *) @" SHAKE !!! ";
[self setNeedsDisplay];
}
if ([super respondsToSelector:@selector(motionEnded:withEvent:)]) {
[super motionEnded:motion withEvent:event];
}
}
but gestures are a no go.
Code:
- (void)ViewDidAppear
{
UISwipeGestureRecognizer *oneFingerSwipeLeft =
[[[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(oneFingerSwipeLeft:)] autorelease];
[oneFingerSwipeLeft setDirection:UISwipeGestureRecognizerDirectionLeft];
[self addGestureRecognizer:oneFingerSwipeLeft];
}
- (void)oneFingerSwipeLeft:(UISwipeGestureRecognizer *)recognizer
{
NSLog(@"Swipe Left");
CGPoint point = [recognizer locationInView:self];
NSLog(@"Swipe left - start location: %f,%f", point.x, point.y);
}
Zero error but I did have to trigger ViewDidAppear manually (I did try viewDidAppear nothing triggered) from Delegate.
long and short of the question:
Will gestures only work in a NSViewcontroller ?
or is there another way to get gestures to work in a UIView?
One thing might be I have a layer of buttons on the window (which is on top of the view) but don't start the swipe on any of them when I'm testing it.
*** Ok thinking (as I wrote) about this I add the UISwipeGestureRecognizer to the window and it worked !! I guess because it was the top layer.
But one thing comes to mind .. should I rejig my code to put all the buttons and shake on separate views working under a view controller and put next to nothing in the window myAppDelegate.. ??? is that better form?
thanks fir your help
Ian