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 > iPhone SDK Development - Advanced Discussion

Reply
 
LinkBack Thread Tools Display Modes
Old 02-06-2011, 10:31 AM   #1 (permalink)
Registered Member
 
Join Date: Jan 2011
Posts: 24
jackosx is on a distinguished road
Default Help dragging UIImageView

As soon as I begin to drag a UIImageView, my app crashes. I haven't been able to figure out what is wrong with my code, I've looked all over for an answer, but no matter what I try it doesn't work. Here's my code
Code:
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
	UITouch *touch = [[event allTouches] anyObject];
	if ([touch view] == you) {
		touched = TRUE;
	}
}

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {	
	UITouch *touch = [touches anyObject];
	if (touched == TRUE) {
		CGPoint location = [touch locationInView:self];
		CGPoint xlocation = CGPointMake(location.x, 220); 
		you.center = xlocation;		
		return;
	}
}
jackosx is offline   Reply With Quote
Old 02-06-2011, 01:11 PM   #2 (permalink)
Super Moderator
 
Join Date: Oct 2009
Location: San Diego, CA
Posts: 1,586
JasonR is on a distinguished road
Default

Which line does it crash on? On a first guess, I would suspect "you" should be replaced by "self".
JasonR is offline   Reply With Quote
Old 02-06-2011, 02:09 PM   #3 (permalink)
Registered Member
 
Join Date: Jan 2011
Posts: 24
jackosx is on a distinguished road
Default

Quote:
Originally Posted by JasonR View Post
Which line does it crash on? On a first guess, I would suspect "you" should be replaced by "self".
"you" is the name of the UIImageView, so I think that should remain as that, and I get this warning: incompatible Objective-C types 'struct RoadRunnerViewController *', expected 'struct UIView *' when passing argument 1 of 'locationInView:' from distinct Objective-C type on this line:
Code:
CGPoint location = [touch locationInView:self];
The console says this:
Code:
2011-02-06 15:08:15.951 RoadRunner[898:207] ******* Accessibility Status Changed: On
2011-02-06 15:08:15.975 RoadRunner[898:207] ********** Loading AX for: com.yourcompany.RoadRunner ************
2011-02-06 15:08:17.190 RoadRunner[898:207] -[RoadRunnerViewController convertPoint:fromView:]: unrecognized selector sent to instance 0x8266d90
2011-02-06 15:08:17.193 RoadRunner[898:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[RoadRunnerViewController convertPoint:fromView:]: unrecognized selector sent to instance 0x8266d90'
*** Call stack at first throw:
(
	0   CoreFoundation                      0x026a8b99 __exceptionPreprocess + 185
	1   libobjc.A.dylib                     0x027f840e objc_exception_throw + 47
	2   CoreFoundation                      0x026aa6ab -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
	3   CoreFoundation                      0x0261a2b6 ___forwarding___ + 966
	4   CoreFoundation                      0x02619e72 _CF_forwarding_prep_0 + 50
	5   UIKit                               0x00433697 -[UITouch locationInView:] + 231
	6   RoadRunner                          0x0000399f -[RoadRunnerViewController touchesMoved:withEvent:] + 93
	7   UIKit                               0x00382748 forwardMethod2 + 92
	8   UIKit                               0x00382748 forwardMethod2 + 92
	9   UIKit                               0x002df37a -[UIWindow _sendTouchesForEvent:] + 481
	10  UIKit                               0x002c0cb4 -[UIApplication sendEvent:] + 447
	11  UIKit                               0x002c59bf _UIApplicationHandleEvent + 7672
	12  GraphicsServices                    0x02f88822 PurpleEventCallback + 1550
	13  CoreFoundation                      0x02689ff4 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
	14  CoreFoundation                      0x025ea807 __CFRunLoopDoSource1 + 215
	15  CoreFoundation                      0x025e7a93 __CFRunLoopRun + 979
	16  CoreFoundation                      0x025e7350 CFRunLoopRunSpecific + 208
	17  CoreFoundation                      0x025e7271 CFRunLoopRunInMode + 97
	18  GraphicsServices                    0x02f8700c GSEventRunModal + 217
	19  GraphicsServices                    0x02f870d1 GSEventRun + 115
	20  UIKit                               0x002c9af2 UIApplicationMain + 1160
	21  RoadRunner                          0x00001e74 main + 102
	22  RoadRunner                          0x00001e05 start + 53
)
terminate called after throwing an instance of 'NSException'
jackosx is offline   Reply With Quote
Old 02-07-2011, 10:45 AM   #4 (permalink)
Super Moderator
 
Join Date: Oct 2009
Location: San Diego, CA
Posts: 1,586
JasonR is on a distinguished road
Default

In that case, you should probably use you in that line that's crashing as well:
Code:
CGPoint location = [touch locationInView:you];
JasonR is offline   Reply With Quote
Reply

Bookmarks

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: 396
16 members and 380 guests
Brandt, coolman, fredidf, Free App Monster, givensur, iAppDeveloper, jbro, Kryckter, locombiano89, Mah6447, Meoz, simplymuzik3, SLIC, stevenkik, Tomsky, WeaselPig
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,646
Threads: 94,111
Posts: 402,862
Top Poster: BrianSlick (7,990)
Welcome to our newest member, locombiano89
Powered by vBadvanced CMPS v3.1.0

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