2013-12-10 6 views
5
पर काम नहीं कर

मैं अपने FYImageSequence.m file.I में इन 2 कार्यों हो रहा है UIImageViewtouchesBegan और touchesmoved कार्यों UIImageView

से
@interface FVImageSequence : UIImageView 

मैं storyboard.But में मेरे UIImageView को यह कनेक्ट करने में सक्षम था वर्ग विरासत में मिला काम करने के नीचे काम कैसे करें। क्या कोई कनेक्शन है जो किया जाना चाहिए।

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{ 
if(increment == 0) 
    increment = 1; 
    [super touchesBegan:touches withEvent:event]; 

    UITouch *touch = [[event allTouches] anyObject]; 
    CGPoint touchLocation = [touch locationInView:self]; 
    previous = touchLocation.x; 
} 

-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { 
[super touchesMoved:touches withEvent:event]; 

    UITouch *touch = [[event allTouches] anyObject]; 
    CGPoint touchLocation = [touch locationInView:self]; 
int location = touchLocation.x; 

if(location < previous) 
    current += increment; 
else 
    current -= increment; 

previous = location; 

if(current > numberOfImages) 
    current = 0; 
if(current < 0) 
    current = numberOfImages; 

NSString *path = [NSString stringWithFormat:@"%@%d", prefix, current]; 
NSLog(@"%@", path); 

path = [[NSBundle mainBundle] pathForResource:path ofType:extension]; 


UIImage *img = [[UIImage alloc] initWithContentsOfFile:path]; 

[self setImage:img]; 
} 

उत्तर

9

UIImageView का उपयोगकर्ता इंटरैक्शन डिफ़ॉल्ट रूप से NO है। तो तुम बनाने के लिए यह हाँ इस

self.userInteractionEnabled = YES; 
2

सेट YES छवि देखने पर करने के लिए UserInteractionEnabled

0

इसके लिए तरह की जरूरत है, मैं विधि, और नहीं चर (किसी भी तरह चर सीधा नहीं पहुंचा था) का इस्तेमाल किया था, इसलिए:
[आत्म setUserInteractionEnabled: हाँ];