IanClickImageView.m 927 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. //
  2. // XYWebOnRedirectRequestURLProtocol.m
  3. // Starbuds
  4. //
  5. // Created by 翟玉磊 on 2020/5/30.
  6. // Copyright © 2020 翟玉磊. All rights reserved.
  7. //
  8. #import "IanClickImageView.h"
  9. @implementation IanClickImageView
  10. - (id)initWithFrame:(CGRect)frame
  11. {
  12. self = [super initWithFrame:frame];
  13. if (self) {
  14. // Initialization code
  15. self.userInteractionEnabled=YES;
  16. }
  17. return self;
  18. }
  19. -(void)addTarget:(id)target action:(SEL)action
  20. {
  21. self.target = target;
  22. self.action = action;
  23. }
  24. -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
  25. {
  26. //如果self.target表示的对象中, self.action表示的方法存在的话
  27. if([self.target respondsToSelector:self.action])
  28. {
  29. #pragma clang diagnostic push
  30. #pragma clang diagnostic ignored "-Warc-performSelector-leaks"
  31. [self.target performSelector:self.action withObject:self];
  32. #pragma clang diagnostic pop
  33. }
  34. }
  35. @end