02-06-2011, 10:31 AM
#1 (permalink )
Registered Member
Join Date: Jan 2011
Posts: 24
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;
}
}
02-06-2011, 01:11 PM
#2 (permalink )
Super Moderator
Join Date: Oct 2009
Location: San Diego, CA
Posts: 1,586
Which line does it crash on? On a first guess, I would suspect "you" should be replaced by "self".
02-06-2011, 02:09 PM
#3 (permalink )
Registered Member
Join Date: Jan 2011
Posts: 24
Quote:
Originally Posted by
JasonR
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'
02-07-2011, 10:45 AM
#4 (permalink )
Super Moderator
Join Date: Oct 2009
Location: San Diego, CA
Posts: 1,586
In that case, you should probably use you in that line that's crashing as well:
Code:
CGPoint location = [touch locationInView:you];
Thread Tools
Display Modes
Linear Mode
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
» 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