ReaderThumbView.m 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. //
  2. // ReaderThumbView.m
  3. // Reader v2.8.6
  4. //
  5. // Created by Julius Oklamcak on 2011-09-01.
  6. // Copyright © 2011-2015 Julius Oklamcak. All rights reserved.
  7. //
  8. // Permission is hereby granted, free of charge, to any person obtaining a copy
  9. // of this software and associated documentation files (the "Software"), to deal
  10. // in the Software without restriction, including without limitation the rights to
  11. // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
  12. // of the Software, and to permit persons to whom the Software is furnished to
  13. // do so, subject to the following conditions:
  14. //
  15. // The above copyright notice and this permission notice shall be included in all
  16. // copies or substantial portions of the Software.
  17. //
  18. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  19. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  20. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  21. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  22. // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  23. // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  24. //
  25. #import "ReaderThumbView.h"
  26. @implementation ReaderThumbView
  27. {
  28. NSOperation *_operation;
  29. NSUInteger _targetTag;
  30. }
  31. #pragma mark - Properties
  32. @synthesize operation = _operation;
  33. @synthesize targetTag = _targetTag;
  34. #pragma mark - ReaderThumbView instance methods
  35. - (instancetype)initWithFrame:(CGRect)frame
  36. {
  37. if ((self = [super initWithFrame:frame]))
  38. {
  39. self.autoresizesSubviews = NO;
  40. self.userInteractionEnabled = NO;
  41. self.contentMode = UIViewContentModeRedraw;
  42. self.autoresizingMask = UIViewAutoresizingNone;
  43. self.backgroundColor = [UIColor clearColor];
  44. imageView = [[UIImageView alloc] initWithFrame:self.bounds];
  45. imageView.autoresizesSubviews = NO;
  46. imageView.userInteractionEnabled = NO;
  47. imageView.autoresizingMask = UIViewAutoresizingNone;
  48. imageView.contentMode = UIViewContentModeScaleAspectFit;
  49. [self addSubview:imageView];
  50. }
  51. return self;
  52. }
  53. - (void)showImage:(UIImage *)image
  54. {
  55. imageView.image = image; // Show image
  56. }
  57. - (void)showTouched:(BOOL)touched
  58. {
  59. // Implemented by ReaderThumbView subclass
  60. }
  61. - (void)removeFromSuperview
  62. {
  63. _targetTag = 0; // Clear target tag
  64. [self.operation cancel]; // Cancel operation
  65. [super removeFromSuperview]; // Remove view
  66. }
  67. - (void)reuse
  68. {
  69. _targetTag = 0; // Clear target tag
  70. [self.operation cancel]; // Cancel operation
  71. imageView.image = nil; // Release image
  72. }
  73. @end