DetailViewController.m 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*
  2. * This file is part of the SDWebImage package.
  3. * (c) Olivier Poitrey <rs@dailymotion.com>
  4. *
  5. * For the full copyright and license information, please view the LICENSE
  6. * file that was distributed with this source code.
  7. */
  8. #import "DetailViewController.h"
  9. #import <SDWebImage/SDWebImage.h>
  10. @interface DetailViewController ()
  11. @property (strong, nonatomic) IBOutlet SDAnimatedImageView *imageView;
  12. @end
  13. @implementation DetailViewController
  14. - (void)configureView {
  15. if (!self.imageView.sd_imageIndicator) {
  16. self.imageView.sd_imageIndicator = SDWebImageProgressIndicator.defaultIndicator;
  17. }
  18. [self.imageView sd_setImageWithURL:self.imageURL
  19. placeholderImage:nil
  20. options:SDWebImageProgressiveLoad | SDWebImageScaleDownLargeImages
  21. context:@{SDWebImageContextImageForceDecodePolicy: @(SDImageForceDecodePolicyNever)}
  22. ];
  23. self.imageView.shouldCustomLoopCount = YES;
  24. self.imageView.animationRepeatCount = 0;
  25. }
  26. - (void)viewDidLoad {
  27. [super viewDidLoad];
  28. [self configureView];
  29. self.navigationItem.rightBarButtonItem = [UIBarButtonItem.alloc initWithTitle:@"Toggle Animation"
  30. style:UIBarButtonItemStylePlain
  31. target:self
  32. action:@selector(toggleAnimation:)];
  33. }
  34. - (void)toggleAnimation:(UIResponder *)sender {
  35. self.imageView.isAnimating ? [self.imageView stopAnimating] : [self.imageView startAnimating];
  36. }
  37. @end