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 06-09-2010, 01:59 PM   #1 (permalink)
Registered Member
 
Join Date: Jun 2010
Posts: 13
Missing.Matter is on a distinguished road
Question touchesCancelled called unexpectedly

I'm writing a checkers game based on the Apple Autoscroll example (http://developer.apple.com/iphone/li...inkElementID_2), and I'm having trouble with moving the game piece; touchesCancelled fires if I move the game piece more than a few pixels, thus stopping the movement.

The code, which I've attached, revolves around 2 classes: TokenImageView, which handles all the token touch events; and RootViewController, which adds all the scroll and image views and acts as the TokenImageView delegate.

As far as I can tell, the code is doing exactly what I want it to do, except that after I move the game piece a little I get a touchesCancelled event, which I can't explain.

What causes this event to fire? Apple documentation says a memory warning will do this. I don't see memory growing as I move the tokens, am I missing something?

This code is largely based off Apple's code, so it's quite possible I did something fundamentally wrong when I changed the code.

I look forward to hearing your thoughts.

Edit: After closer examination, the touchesCancelled event is called only after the token is moved a certain distance from the origin. The token can move indefinitely as long as it stays within ~10 pixels from where it started.

I should also note I'm testing this in the simulator only, so that takes away the possibility of multiple touches.
Attached Files
File Type: zip Token.zip (68.3 KB, 13 views)

Last edited by Missing.Matter; 06-09-2010 at 02:14 PM.
Missing.Matter is offline   Reply With Quote
Old 06-09-2010, 02:39 PM   #2 (permalink)
Registered Member
 
Join Date: Jun 2010
Posts: 13
Missing.Matter is on a distinguished road
Default

I've found the answer to my problem, for anyone who reads this in the future: The game board scrollview has a property called "CanCancelContentTouches" which needs to be set to "NO"

By default, this property is set to YES, and it will cancel a touch on any sub view if it thinks the touch should actually be scrolling the scrollview.
Missing.Matter is offline   Reply With Quote
Old 01-12-2011, 08:05 PM   #3 (permalink)
Registered Member
 
Join Date: Aug 2009
Location: Tasmania, Australia
Posts: 195
Son of a Beach is on a distinguished road
Default

Thanks for posting your solution. I've been battling with this issue all day, and you have solved it for me!!!! :-)
Son of a Beach is offline   Reply With Quote
Reply

Bookmarks

Tags
board game, dragging, touchescancelled, uiscrollview

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: 334
12 members and 322 guests
Absentia, Domele, fiftysixty, givensur, heshiming, iGamesDev, linkmx, michaelhansen, PixelInteractive, raihan.zbr, Sloshmonster
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,657
Threads: 94,118
Posts: 402,892
Top Poster: BrianSlick (7,990)
Welcome to our newest member, jenniead38
Powered by vBadvanced CMPS v3.1.0

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