Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 03-13-2010, 07:29 AM   #14 (permalink)
moonshiner
Registered Member
 
Join Date: Mar 2010
Posts: 8
moonshiner is on a distinguished road
Default

The way I check if touch is held is I declare a UItouch pointer in the header files. When a touch happens, I set the UItouch to the touch that has been passed in.

When touches end, I simply set that to nil.

To find out if the a touch is held down, I check to see if its is valid. It will be valid anytime before the touch is ended

Code:
//in header
UITouch *touch;

//start of touch
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
     
     touch = [touches anyObject];
}

//when touches end
- (BOOL)touchesEnded:(NSSet*)touches withEvent:(UIEvent*)event{

     NSArray *touchArray = [touches allObjects];
     int count = [touchArray count];
     for(int i = 0; i < count; i++)
     { 
          if(touchArray[i] == touch)
               touch = nil;
     }
}

Last edited by moonshiner; 03-13-2010 at 10:04 PM.
moonshiner is offline   Reply With Quote
 

» Advertisements
» Stats
Members: 175,539
Threads: 94,055
Posts: 402,653
Top Poster: BrianSlick (7,982)
Welcome to our newest member, cecilytw61
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 12:12 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.