Page 1 of 4 1234 LastLast
Results 1 to 10 of 31
Discuss [Advice] No touch events happening at the iPhone Developer Exchange - Hackint0sh.org; Hi, I cant get touches to register in my app, I have the following, Code: ...
  1. #1
    Advanced Array

    Join Date
    Feb 2008
    Posts
    45
    Post Thanks / Like
    Downloads
    0
    Uploads
    0
    Rep Power
    0

    Default [Advice] No touch events happening

    Hi, I cant get touches to register in my app, I have the following,

    Code:
    - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
    
    {
    	NSLog(@"Touch Down ");
    }
    But I never get the NSLog message.

    Any ideas?
    Last edited by Pyrofer; 06-28-2008 at 06:47 PM.



  2. #2
    Developer Array javacom's Avatar

    Join Date
    Mar 2008
    Posts
    304
    Post Thanks / Like
    Downloads
    0
    Uploads
    0
    Rep Power
    28

    Default

    It should be
    Code:
    - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event

    Quote Originally Posted by Pyrofer View Post
    Hi, I cant get touches to register in my app, I have the following,

    Code:
    - (void)notouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
    
    {
    	NSLog(@"Touch Down ");
    }
    But I never get the NSLog message.

    Any ideas?

  3. #3
    Advanced Array

    Join Date
    Feb 2008
    Posts
    45
    Post Thanks / Like
    Downloads
    0
    Uploads
    0
    Rep Power
    0

    Default

    haha, yeah, sorry. That got pasted in by accident. It IS as you show
    Code:
    -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
    Still doesnt work
    None of the others such as touchesEnded work either.
    I never get the NSLog happening.

  4. #4
    Advanced Array

    Join Date
    Feb 2008
    Posts
    45
    Post Thanks / Like
    Downloads
    0
    Uploads
    0
    Rep Power
    0

    Default

    Come on please!
    Nobody have a clue?
    I tried accelerometer input as well and it seems the events are never triggered. I never get the NSLog message from inside the routine.
    What do I have to do to activate whatever it is that triggers/calls these routines?

  5. #5
    Developer Array javacom's Avatar

    Join Date
    Mar 2008
    Posts
    304
    Post Thanks / Like
    Downloads
    0
    Uploads
    0
    Rep Power
    28

    Default

    Try to overwrite these touch methods using a UIView subclass.

    You may want to try some sample Apps from Apple.


  6. #6
    Advanced Array

    Join Date
    Feb 2008
    Posts
    45
    Post Thanks / Like
    Downloads
    0
    Uploads
    0
    Rep Power
    0

    Default

    I started my app using the new project thingy in the SDK.
    Ive worked almost every line of code out from the example apps, i just have no idea why these methods dont work.
    Can you show a small snippet example of how I should "overwrite these touch methods using a UIView subclass" ? please?

  7. #7
    Developer Array javacom's Avatar

    Join Date
    Mar 2008
    Posts
    304
    Post Thanks / Like
    Downloads
    0
    Uploads
    0
    Rep Power
    28

    Default

    Here are the codes, just use the Cocoa Touch Project Template and change the MyView.h and MyView.m as below

    Code:
    //
    //  MyView.h
    //  Touches.app
    //
    
    #import <UIKit/UIKit.h>
    
    @interface MyView : UIView {
    	UILabel *label;
    }
    
    @end
    Code:
    //
    //  MyView.m
    //  Touches.app
    //
    #import "MyView.h"
    
    @implementation MyView
    - (id)initWithFrame:(CGRect)frame {
        if (self = [super initWithFrame:frame]) {
            // Initialization code.
    		self.backgroundColor =[UIColor blackColor];
    		label =  [[UILabel alloc] initWithFrame:CGRectMake(self.frame.origin.x, self.frame.origin.y, self.frame.size.width, 20)];
    		// Set the font size, text color, background color, and alignment.
    		label.font = [UIFont systemFontOfSize:18.0];
    		label.textColor = [UIColor lightTextColor];
    		label.backgroundColor = [UIColor clearColor];
    		label.textAlignment = UITextAlignmentCenter;
    		// Set the number of lines
    		label.numberOfLines = 1;
    		// Initialize as a string
    		label.text = @"Hello";
    		label.center = self.center;
    		[self addSubview:label];
        }
        return self;
    }
    
    - (void)drawRect:(CGRect)rect {
        // Drawing code.
    }
    
    - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
    {
    	label.text = @"Touch Began";
    }
    
    - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
    {  
    	label.text = @"Touch Ended";
    }
    
    - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
    { 	
    	label.text = @"Touch Moved";
    }
    
    - (void)dealloc {
    	[super dealloc];
    }
    
    @end
    Last edited by javacom; 07-01-2008 at 04:50 AM.

  8. #8
    Advanced Array

    Join Date
    Feb 2008
    Posts
    45
    Post Thanks / Like
    Downloads
    0
    Uploads
    0
    Rep Power
    0

    Default

    There was nothing wrong with my code, it was the way I started the project.

    I started a ne project as a view app, just pasted in all my actual code and ran with no changes.
    it works.

    Now I have a different problem. How do I get just a simple x/y location for the touch?
    I have,
    Code:
    UITouch *touch=[[event touchesForView:self] anyobject];
    CGPoint touchpoint=[touch locationInView:self];
    NSLog(@"Touch %d",touchpoint.x);
    But I always get zero, no matter where i touch.

    Also, I only get touches in my appViewController.m not the appAppDelegate.m where I need them.
    How do I pass the info over to the appDelegate to perform an action? My variables dont seem to be accessable from the AppViewController
    Last edited by Pyrofer; 07-01-2008 at 02:57 PM.

  9. #9
    Developer Array javacom's Avatar

    Join Date
    Mar 2008
    Posts
    304
    Post Thanks / Like
    Downloads
    0
    Uploads
    0
    Rep Power
    28

    Default

    Quote Originally Posted by Pyrofer View Post
    There was nothing wrong with my code, it was the way I started the project.

    I started a ne project as a view app, just pasted in all my actual code and ran with no changes.
    it works.
    That's what I said in post#5 to use UIView subclass.

  10. #10
    Advanced Array

    Join Date
    Feb 2008
    Posts
    45
    Post Thanks / Like
    Downloads
    0
    Uploads
    0
    Rep Power
    0

    Default

    Thanks for all your help!
    I appreciate this a lot.
    I still cant figure out why all touches are 0 though.

    I want to get a simple x/y location for each touch but cant manage it at all!


 

 
Page 1 of 4 1234 LastLast

Similar Threads

  1. Why is this happening? SSH...
    By seseberg in forum Tools
    Replies: 3
    Last Post: 10-27-2008, 06:21 AM
  2. [Advice] New iPod Touch coming up ?
    By iamrygar in forum iPod Touch 1G
    Replies: 4
    Last Post: 07-16-2008, 04:48 AM
  3. [Advice] iPod Touch grey wifi
    By jameselder232 in forum iPod Touch 1G
    Replies: 11
    Last Post: 06-14-2008, 11:01 AM
  4. [installer] what is happening to it !
    By balboula_85 in forum Free Toolchain Software (Cydia App's)
    Replies: 0
    Last Post: 02-05-2008, 02:00 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Powered by vBulletin®
Copyright © 2014 vBulletin Solutions, Inc. All rights reserved.
Search Engine Friendly URLs by vBSEO
(c) 2006-2012 Hackint0sh.org
All times are GMT +2. The time now is 09:22 AM.
twitter, follow us!