Search Results

Search found 143 results on 6 pages for 'touchesbegan'.

Page 1/6 | 1 2 3 4 5 6  | Next Page >

  • touchesBegan / Ended incorrectly identifying second, third, etc. touch

    - by Rob
    I have an issue where touchesBegan and touchesEnded are incorrectly identifying my second, third, etc touch if I continue to hold down my first touch. If I lift my finger up off the first touch, then it will recognize the next touch just fine. It's only when I hold my first touch down continuously and then try and touch a different area with a different finger at the same time. It will then incorrectly register that second touch as being from the first touch again. Any insights into how I can fix this? - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { UITouch* touch = [touches anyObject]; NSString* filename = [listOfStuff objectAtIndex:[touch view].tag]; // do something with the filename now } - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { ITouch* touch = [touches anyObject]; NSString* buttonPressed = [listOfStuff objectAtIndex:[touch view].tag]; // do something with this info now }

    Read the article

  • iPhone multitouch - Some touches dispatch touchesBegan: but not touchesMoved:

    - by zkarcher
    I'm developing a multitouch application. One touch is expected to move, and I need to track its position. For all other touches, I need to track their beginnings and endings, but their movement is less critical. Sometimes, when 3 or more touches are active, my UIView does not receive touchesMoved: events for the moving touch. This problem is intermittent, and can always be reproduced after a few attempts: Touch the screen with 2 fingers. Touch the screen with another finger, and move this finger around. The moving finger always dispatches touchesBegan: and touchesEnded:, but sometimes does not dispatch any touchesMoved: events. Whenever the moving touch does not dispatch touchesMoved: events, I can force it to dispatch touchesMoved: if I move one of the other touches. This seems to "force" every touch to recheck its position, and I successfully receive a touchesMoved: event. However, this is clumsy. This bug is reproducible on both the iPhone 2G and 3GS models. My question is: How do I ensure that my moving touch dispatches touchesMoved: events? Does anyone have any experience with this issue? I've spent few fruitless days searching the web for answers. I found a post describing how to sync touch events with the VBL: http://www.71squared.com/2009/04/maingameloop-changes/ . However, this has not solved the problem. I really don't know how to proceed. Any help is appreciated!

    Read the article

  • Error message when trying to insert method into touchesBegan

    - by Rob
    I am trying to create a new method within my TapDetectingImageView file and it's giving me a warning that it cannot find the method even though I have it declared in the .h file. The specific three warnings all point to the @end line in the .m file when I build it and they say: "Incomplete implementation of class 'TapDetectingImageView' ; 'Method definition for '-functionA:' not found" ; "Method definition for '-functionB:' not found" What am I missing? Am I not allowed to do this in a protocol file like TapDetectingImageView? In my .h file is: @interface TapDetectingImageView : UIImageView <AVAudioPlayerDelegate> { id <TapDetectingImageViewDelegate> delegate; } @property (nonatomic, assign) id <TapDetectingImageViewDelegate> delegate; -(void) functionA:(NSString*)aVariable; -(void) functionB:(NSString*)aVariable; @end In my .m file is: -(void)functionA:(NSString*)aVariable { // do stuff in this function with aVariable } -(void)functionB:(NSString*)aVariable { // do stuff in this function with aVariable }

    Read the article

  • How do you tell what object is being touched in touchesBegan?

    - by Flafla2
    I know that this is a very commonly asked question, but all of the answers on every website don't work! If you still don't know what I mean, then maybe this line of code will help you understand. - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [[event allTouches] anyObject]; CGPoint location = [touch locationInView:self.view]; if (touch.view == nextbutton) [self performSelector:@selector(next)]; if (touch.view == prevbutton) [self performSelector:@selector(previous)]; if (touch.view == moreoptionsbutton) [self performSelector:@selector(moresettings)]; } It doesn't do anything when you touch nextbutton, prevbutton, and more optionsbutton, which are UIImageViews by the way. I have also tried using isEqual: instead of ==, but that hasn't worked out either. Any suggestions?

    Read the article

  • New to iPhone SDK: touchesBegan not called

    - by coriolan
    Hi, I created a very very basic iPhone app with File/New Projet/View-Based application. No NIB file there. Here is my appDelegate .h @interface MyAppDelegate : NSObject <UIApplicationDelegate> { UIWindow *window; MyViewController *viewController; } .m - (void)applicationDidFinishLaunching:(UIApplication *)application { // Override point for customization after app launch [window addSubview:viewController.view]; [window makeKeyAndVisible]; } And here is my loadView method in my controller - (void)loadView { CGRect mainFrame = [[UIScreen mainScreen] applicationFrame]; UIView *contentView = [[UIView alloc] initWithFrame:mainFrame]; contentView.backgroundColor = [UIColor redColor]; self.view = contentView; [contentView release]; } Now, in order to catch the touchesBegan event, I created a new subclass of UIView: .h @interface TouchView : UIView { } .m - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { NSLog(@"Touch detected"); } and modified the second line in my loadView into this : TouchView *contentView = [[UIView alloc] initWithFrame:mainFrame]; Why is touchesBegan never called?

    Read the article

  • How to reset buttons when using touchesBegan

    - by FireStorm
    When I use touchesBegan on my sprite kit game the buttons press down fine the first time but are unresponsive the second time, how do I "reset" these buttons if you will. Buttons are as follows: - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [touches anyObject]; CGPoint location = [touch locationInNode:self]; SKNode *node = [self nodeAtPoint:location]; if ([node.name isEqualToString:@"Button"]) { [self runAction:[SKAction playSoundFileNamed:@"sound" waitForCompletion: NO]]; .... Thanks for your help!

    Read the article

  • How to create Button dynamically in -(void)touchesBegan() function call in iPad

    - by chaitanya
    HI, I am trying to create buttons and text views on touch events from WebView. I am creating the Button creation code in below code. -(void)touchesBegan: ( NSSet* )touches withEvent : (UIEvent ) event{ } capturng of the touch events is happening properly and above fucntion is called also. But the button creation is not happening. PLease suggest that what could be the issue with approach.

    Read the article

  • touchesBegan and other touch events not getting detected in UINavigationController

    - by SaltyNuts
    In short, I want to detect a touch on the navigation controller titlebar, but having trouble actually catching any touches at all! Everything is done without IB, if that makes a difference. My app delegate's .m file contains: MyViewController *viewController = [[MyViewController alloc] init]; navigationController = [[UINavigationController alloc] initWithRootViewController:viewController]; [window addSubview:navigationController.view]; There are a few other subviews added to this window in a way that overlays navigationController leaving only the navigation bar visible. MyViewController is a subclass of UIViewController and its .m file contains: - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { for (UITouch *touch in touches) { NSLog(@"ended\n"); } } -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { for (UITouch *touch in touches) { NSLog(@"began\n"); } } I also tried putting these functions directly into app delegate's .m file, but the console remains blank. What am I doing wrong?

    Read the article

  • touchesBegan doesnt get detected

    - by Muniraj
    I have a viewcontroller like the following. But the touchsBegan doestnt get detected. Can anyone plz tell me what is wrong. - (id)init { if (self = [super init]) self.view = [[[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]] autorelease]; return self; } -(void) viewWillAppear:(BOOL)animated { overlay = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"overlay.png"]] autorelease]; [self.view addSubview:overlay]; } - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { // Detect touch anywhere UITouch *touch = [touches anyObject]; // Where is the point touched CGPoint point = [touch locationInView:self.view]; NSLog(@"pointx: %f pointy:%f", point.x, point.y); // Was a tab touched, if so, which one... if (CGRectContainsPoint(CGRectMake(1, 440, 106, 40), point)) NSLog(@"tab 1 touched"); else if (CGRectContainsPoint(CGRectMake(107, 440, 106, 40), point)) NSLog(@"tab 2 touched"); else if (CGRectContainsPoint(CGRectMake(214, 440, 106, 40), point)) NSLog(@"tab 3 touched"); }

    Read the article

  • How to add images while moving finger across UIView?

    - by Luke Irvin
    I am having issues adding an image across a view while moving finger across the screen. Currently it is adding the image multiple times but squeezing them too close together and not really following my touch. Here is what I am trying: -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { UITouch * touch = [touches anyObject]; touchPoint = [touch locationInView:imageView]; if (touchPoint.x > 0 && touchPoint.y > 0) { _aImageView = [[UIImageView alloc] initWithImage:aImage]; _aImageView.multipleTouchEnabled = YES; _aImageView.userInteractionEnabled = YES; [_aImageView setFrame:CGRectMake(touchPoint.x, touchPoint.y, 80.0, 80.0)]; [imageView addSubview:_aImageView]; [_aImageView release]; } } -(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { [self touchesBegan:touches withEvent:event]; } Any suggestions is much appreciated. EDIT: What I want: After taking or choosing an image, the user can then select another image from a list. I want the user to touch and move their finger across the view and the selected image will appear where they drag their finger, without overlapping, in each location.

    Read the article

  • How to ask UIImageView if MultipleTouchEnabled is "YES"

    - by Rob
    I have created a few UIImageViews programmatically, but I have a feeling that even though I setMultipleTouchEnabled to YES during the setup, it is not getting set properly and it's leading to multi-touch issues. My question is, within touchesBegan how do I go about asking the UIImageView that was touched if it has MultipleTouchEnabled or not? I am fairly new to this so I'm really stumbling through code and learning as I go (with your help of course). Thank you ahead of time!

    Read the article

  • touchesEnded not being called??? or randomly being called

    - by Rob
    If I lift my finger up off the first touch, then it will recognize the next touch just fine. It's only when I hold my first touch down continuously and then try and touch a different area with a different finger at the same time. It will then incorrectly register that second touch as being from the first touch again. Update It has something to do with touchesEnded not being called until the very LAST touch has ended (it doesn't care if you already had 5 other touches end before you finally let go of the last one... it calls them all to end once the very last touch ends) - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { UITouch* touch = [touches anyObject]; NSString* filename = [listOfStuff objectAtIndex:[touch view].tag]; // do something with the filename now } - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { ITouch* touch = [touches anyObject]; NSString* buttonPressed = [listOfStuff objectAtIndex:[touch view].tag]; // do something with this info now }

    Read the article

  • How can I load a view based on how long I hold a UIButton?

    - by Thomas
    Hello all, I've searched the net and documentation, but haven't found anything quite like what I'm trying to do. I'm working on an app where I want to load one view if a UIButton is held for x seconds, another if it's held for x+y seconds, etc. I found this tutorial. The problem I'm running into is, how do I switch the length of the button press? The tutorial switched the number of taps. -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { NSSet *allTouches = [event allTouches]; switch ([allTouches count]) { case 1: // Single touch { // Get the first touch. UITouch *touch = [[allTouches allObjects] objectAtIndex:0]; switch ([touch tapCount]) { case 1: // Single Tap. { // Start a timer timer = [NSTimer scheduledTimerWithTimeInterval:2 target:self selector:@selector(showAlertView:) userInfo:nil repeats:NO]; [timer retain]; } break; case 2: // Double tap. break; } } break; case 2: // Double touch { } break; default: break; } } Any suggestions? Thanks! Thomas

    Read the article

  • Increase frequency calls of touchesMoved

    - by Erika
    Hi Everyone, Is there a way to increase the frequency calls of touchesMoved than the default? I need more calls of it to draw a smooth circle. It gets called not too frequent by default and so I get an edgy circle. Is there a way to tweek the frequency of touchesMoved calls? Thanks

    Read the article

  • Cocos2D TouchesEnded not allowing me to access sprites?

    - by maiko
    Hey Guys! Thanks so much for reading! - (void)ccTouchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { UITouch * touch = [touches anyObject]; CGPoint location = [[CCDirector sharedDirector] convertToGL: [touch locationInView:touch.view]]; CGRect myRect = CGRectMake(100, 120, 75, 113); int tjx = sprite.position.x; if(CGRectContainsPoint(myRect, location)) { tjx ++; } } For some reason, ccTouchesEnded isn't allowing me to access my "sprite". I also tried to use CGRectMake like so : CGRectMake( sprite.position.x, sprite.position.y, sprite.contentSize.Width, sprite.contentSize.Height) But I couldn't access my sprites position or height. I keep getting "sprite" undeclared when it is declared in the init method, and added to the child. Please help!! I'm sure i'm missing something really simple here.

    Read the article

  • iPhone "touchesBegan" and "touchesMoved" message ... do not move to centre of touch

    - by Nippysaurus
    I am modifying the "MoveMe" example from the apple web site. When I get the "touchesMoved" message I move the centre of the target view to the centre of the touch. Is there a way that when the touch starts ("touchesBegan" message) I can remember the offset from the target view and keep that offset. Let me know if this is hard to understand and I will try to explain it a bit better.

    Read the article

  • Create a screen like the iPhone home screen with Scrollview and Buttons

    - by Anthony Chan
    Hi, I'm working on a project and need to create a screen similar to the iPhone home screen: A scrollview with multiple pages A bunch of icons When not in edit mode, swipe through different pages (even I started the touch on an icon) When not in edit mode, tap an icon to do something When in edit mode, drag the icon to swap places, and even swap to different pages When in edit mode, tap an icon to remove it Previously I read from several forums that I have to subclass UIScrollview in order to have touch input for the UIViews on top of it. So I subclassed it overriding the methods to handle touches: - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { //If not dragging, send event to next responder if (!self.dragging) [self.nextResponder touchesBegan:touches withEvent:event]; else [super touchesBegan:touches withEvent:event]; } In general I've override the touchesBegan:, touchesMoved: and touchesEnded: methods similarly. Then in the view controller, I added to following code: - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [touches anyObject]; UIView *hitView = (UIView *)touch.view; if ([hitView isKindOfClass:[UIView class]]) { [hitView doSomething]; NSLog(@"touchesBegan"); } } - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { // Some codes to move the icons NSLog(@"touchesMoved"); } - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { NSLog(@"touchesEnded"); } When I run the app, I have the touchesBegan method detected correctly. However, when I tried to drag the icon, the icon just moved a tiny bit and then the page started to scroll. In console, it logged with 2 or 3 "touchesMoved" message only. However, I learned from another project that it should logged tonnes of "touchesMoved" message as long as I'm still dragging on the screen. (I'm suspecting I have the delaysContentTouches set to YES, so it delays a little bit when I tried to drag the icons. After that minor delay, it sends to signal back to the scrollview to scroll through the page. Please correct me if I'm wrong.) So if any help on the code to perform the above tasks would be greatly appreciated. I've stuck in this place for nearly a week with no hope. Thanks a lot.

    Read the article

  • Detect ANY touch in a view (iPhone SDK)

    - by David
    Hello, I'm currently using ... - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { to detect swipes. I've got everything working. The only problem is if the user touches on top of something (eg a UIButton or something) the - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { is not called. Is there something like touchesBegan but will work if I touch ANYWHERE on the view? Thanks in advance, David

    Read the article

  • delegate issues in Xcode

    - by trludt
    .h file #import <UIKit/UIKit.h> @interface AddEventViewController : UIViewController <UITextViewDelegate> @end .m file @property (weak, nonatomic) IBOutlet UITextField *textField1; @property (weak, nonatomic) IBOutlet UITextField *textField2; @property (weak, nonatomic) IBOutlet UITextField *textField3; - (IBAction)textFieldReturn:(id)sender; @end @implementation AddEventViewController @synthesize textField1, textField2, textField3; - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { // Custom initialization } return self; } - (IBAction)textFieldReturn:(id)sender; { [sender resignFirstResponder]; } - (void)viewDidLoad { [super viewDidLoad]; self.textField1.delegate = self; textField1.delegate = self; // Do any additional setup after loading the view. } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } - (void)touchesBegan: (NSSet *) touches withEvent: (UIEvent *)event { if (textField1) { if ([textField1 canResignFirstResponder]) [textField1 resignFirstResponder]; } [super touchesBegan: touches withEvent: event]; if (textField2) { if ([textField2 canResignFirstResponder]) [textField2 resignFirstResponder]; } [super touchesBegan: touches withEvent: event]; if (textField3) { if ([textField3 canResignFirstResponder]) [textField3 resignFirstResponder]; } [super touchesBegan: touches withEvent: event]; } - (BOOL)textFieldShouldReturn:(UITextField *)textField { [textField1 resignFirstResponder]; return NO; [textField2 resignFirstResponder]; return NO; [textField3 resignFirstResponder]; return NO; } @end Ok so im getting the yellow bug symbol on the lines: - (void)viewDidLoad { [super viewDidLoad]; self.textField1.delegate = self; textField1.delegate = self; } I don't know how to delegate all of my textFields? how do i make this textFieldReturn work for all of my textFields.. that viewDidLoad area has to be the problem, because everything else works good...

    Read the article

  • Ho can I tell when the background is touched on a UICollectionView?

    - by Mason Cloud
    I've tried subclassing UICollectionView and overriding touchesBegan:withEvent: and hitTest:WithEvent:, and both of those methods trigger when I touch a cell. However, if I touch the space between the cells, nothing happens at all. Here's what I've created: @interface WSImageGalleryCollectionView : UICollectionView @end ..and.. @implementation WSImageGalleryCollectionView - (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { NSLog(@"Touches began"); [super touchesBegan:touches withEvent:event]; } - (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event { NSLog(@"Hit test reached"); return [super hitTest:point withEvent:event]; } @end

    Read the article

  • How to intercept touches events on a MKMapView or UIWebView objects?

    - by Martin
    Hello, I'm not sure what i'm doing wrong but I try to catch touches on a MKMapView object. I subclassed it by creating the following class : #import <UIKit/UIKit.h> #import <MapKit/MapKit.h> @interface MapViewWithTouches : MKMapView { } - (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *) event; @end And the implementation : #import "MapViewWithTouches.h" @implementation MapViewWithTouches - (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *) event { NSLog(@"hello"); //[super touchesBegan:touches withEvent:event]; } @end But it looks like when I use this class, I see nothing on the Console : MapViewWithTouches *mapView = [[MapViewWithTouches alloc] initWithFrame:self.view.frame]; [self.view insertSubview:mapView atIndex:0]; Any idea what I'm doing wrong? Heelp! :) Thanks a lot! Martin

    Read the article

  • Gesture recognizer for mouse down and up in iPhone SDK

    - by user545201
    I want to catch both mouse down and mouse up using gesture recognizer. However, when the mouse down is caught, mouse up is never caught. Here's what I did: First create a custom MouseGestureRecognizer: @implementation MouseGestureRecognizer -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { [super touchesBegan:touches withEvent:event]; self.state = UIGestureRecognizerStateRecognized; } -(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { [super touchesEnded:touches withEvent:event]; self.state = UIGestureRecognizerStateRecognized; } @end Then bind the recognizer to a view in view controller: UIGestureRecognizer *recognizer = [MouseGestureRecognizer alloc] initWithTarget:self action:@selector(handleGesture:)]; [self.view addGestureRecognizer:recognizer]; When I click mouse in the view, the touchesBegan is called, but touchesEnded is never called. Is it because of the UIGestureRecognizerStateRecognized? Any advice will be appreciated! Thanks!

    Read the article

1 2 3 4 5 6  | Next Page >