2012-05-10 5 views
1

я использовал коды ниже, чтобы обнаружить прикосновение к UIImageUIImage не может обнаружить прикосновение

//

#import <UIKit/UIKit.h> 

@interface KUIImageView : UIImageView 
{ 


     CGPoint startLocation; 
} 
@end 


@implementation KUIImageView 

- (id)initWithFrame:(CGRect)frame 
{ 
    self = [super initWithFrame:frame]; 
    if (self) { 
     // Initialization code 
    } 
    return self; 
} 
- (void) touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event { 
    // Retrieve the touch point 
    CGPoint pt = [[touches anyObject] locationInView:self]; 
    startLocation = pt; 
    [[self superview] bringSubviewToFront:self]; 
} 
- (void) touchesMoved:(NSSet*)touches withEvent:(UIEvent*)event { 
    // Move relative to the original touch point 
    CGPoint pt = [[touches anyObject] locationInView:self]; 
    CGRect frame = [self frame]; 
    frame.origin.x += pt.x - startLocation.x; 
    frame.origin.y += pt.y - startLocation.y; 
    [self setFrame:frame]; 
} 



@end 

я поставил точку останова на touchesBegan

Но это не было вызвано

UIImage находился на UIScrollView, используя

[aScrollView addObject:aUIImageView]; 

Все комментарии

ответ

0
- (id)initWithFrame:(CGRect)frame 
{ 
    self = [super initWithFrame:frame]; 
    if (self) { 
     // here 
     self.userInteractionEnabled = YES; 
    } 
    return self; 
} 
Смежные вопросы