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 > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 01-23-2011, 08:28 PM   #1 (permalink)
Registered Member
 
Whitehk's Avatar
 
Join Date: Feb 2010
Posts: 119
Whitehk is on a distinguished road
Default Call touchesMoved with EVERY new touch location

I am drawing a "line" using an image and the touchesMoved event. In touchesMoved, I log the current touch location in a CGPoint. After I do that, I create a UIImageView and add it as a subview to the view. If touches moved continues to be called (meaning the user continues to move their finger), it will continue to make a new UIImageView and add it as a subview, thus creating a "line". However, when I move my finger across the screen too fast, it will break up the line. In other words, touchesMoved isn't getting called every time the user moves their finger to a new location in the view. I want touchesMoved to be called EVERY time the touch location moves (even if that is only by 1 pixel) so that I get a line effect even if the user moves their finger fast. Here's the code I use:

Code:
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
	UITouch *touch = [touches anyObject];
	currentTouch = [touch locationInView:self.view];
	
	CGRect myImageRect = CGRectMake(currentTouch.x, currentTouch.y, 20.0f, 20.0f); 
	UIImageView *myImage = [[UIImageView alloc] initWithFrame:myImageRect];
	[myImage setImage:[UIImage imageNamed:@"ImageUsedToCreateTheLine.png"]];
	[self.view addSubview:myImage];
	[myImage release];
}
Any ideas as to how I can get touchesMoved to be called every time the touch location value changes?
Whitehk is offline   Reply With Quote
Old 01-23-2011, 09:27 PM   #2 (permalink)
Registered Member
iPhone Dev SDK Supporter
 
smasher's Avatar
 
Join Date: Jul 2008
Location: San Mateo, CA (San Fran)
Posts: 3,858
smasher will become famous soon enough
Default

No can do - you won't get touches for each pixel moved, especially when the system is busy drawing your images to the screen.

You'll have to keep track of the last touch position - probably in a CGPoint instance variable - and use a loop to draw a line to the new position.
__________________

Free Games!
smasher is offline   Reply With Quote
Old 01-25-2011, 07:48 PM   #3 (permalink)
Registered Member
 
Whitehk's Avatar
 
Join Date: Feb 2010
Posts: 119
Whitehk is on a distinguished road
Default

Quote:
Originally Posted by smasher View Post
No can do - you won't get touches for each pixel moved, especially when the system is busy drawing your images to the screen.

You'll have to keep track of the last touch position - probably in a CGPoint instance variable - and use a loop to draw a line to the new position.
Darn. I figured it would end up coming to that. Oh well.
Whitehk is offline   Reply With Quote
Reply

Bookmarks

Tags
cgpoint, timer, touchesmoved, uiimageview

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 364
11 members and 353 guests
7twenty7, Clouds, dre, iAppDeveloper, jeroenkeij, Mah6447, Morrisone, sacha1996, Sami Gh, stanny, toon4413
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,667
Threads: 94,121
Posts: 402,899
Top Poster: BrianSlick (7,990)
Welcome to our newest member, host number one
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 03:42 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0