TPCustomImageVIew.m 1 KB
//
//  TPCustomImageVIew.m
//  CNTaipingAgent
//
//  Created by 陈俊俊 on 15/1/28.
//  Copyright (c) 2015年 Taiping. All rights reserved.
//

#import "TPCustomImageVIew.h"

@interface TPCustomImageVIew()
@property (nonatomic,assign) id target;
@property (nonatomic,assign) SEL action;
@end

@implementation TPCustomImageVIew

- (id)initwithTarget:(id)target action:(SEL)action
{
    if (self == [super init]) {
        
        self.userInteractionEnabled = YES;
        UITapGestureRecognizer *tapRecongnizer = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tap)];
        tapRecongnizer.numberOfTapsRequired  = 1;
        [self addGestureRecognizer:tapRecongnizer];
        
        self.target =target;
        self.action = action;
        
    }
    return self;
}

- (void)tap{
    //通过触摸当前的图片视图 让目标对象指向目标对象的行为
    if ([self.target respondsToSelector:self.action]) {
        [self.target performSelector:self.action withObject:self];
    }
}

@end