7

It is very strange that sd_setImageWithURL is working but got an error in sd_setShowActivityIndicatorView:YES and sd_setIndicatorStyle.

Below what I have done.

[cell.cellImgView sd_setShowActivityIndicatorView:YES];
[cell.cellImgView sd_setIndicatorStyle:UIActivityIndicatorViewStyleGray];

[cell.cellImgView sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://img.youtube.com/vi/%@/hqdefault.jpg",[[[galleryDic objectForKey:@"data"] valueForKey:@"Video_id"] objectAtIndex:indexPath.row]]] placeholderImage:[UIImage imageNamed:@"youtube-video"] ];

Please see the image below: enter image description here

Abhishek Mitra
  • 3,335
  • 4
  • 25
  • 46

5 Answers5

11

I figured it out now, Well I have to import #import "UIView+WebCache.h" too along with others then i have used following:

[cell.cellImgView sd_setShowActivityIndicatorView:YES];
[cell.cellImgView sd_setShowActivityIndicatorView:UIActivityIndicatorViewStyleGray];

Also, I removed the SDWebImage folder, what i used to integrate manually, then I have installed it through `POD' again, and now it is working as i wanted.

Abhishek Mitra
  • 3,335
  • 4
  • 25
  • 46
8

For anybody who has this issue in 2019

sd_setShowActivityIndicatorView has been removed in SDWebImage v5

Use this instead

imageView1.sd_imageIndicator = SDWebImageActivityIndicator.gray
//or
imageView2.sd_imageIndicator = SDWebImageProgressIndicator.`default`
//or
imageView2.sd_imageIndicator = SDWebImageActivityIndicator.medium //large, small, gray ...
Husam
  • 8,149
  • 3
  • 38
  • 45
6

I migrate to version 4.0.

and

#import <SDWebImage/UIView+WebCache.h>
2

There is no such method like sd_setShowActivityIndicatorView and sd_setIndicatorStyle in SDWebImage>UIImageView+WebCache.h that's why it shows no visible @interface for UIImageView declares the selector sd_setShowActivityIndicatorView and sd_setIndicatorStyle is not detected

Instead of that use following.

 [cell.cellImgView setShowActivityIndicatorView:YES]; 
 [cell.cellImgView setIndicatorStyle:UIActivityIndicatorViewStyleGray];

Here are these methods in UIImageView+WebCache.h

/**
 *  Show activity UIActivityIndicatorView
 */
- (void)setShowActivityIndicatorView:(BOOL)show;

/**
 *  set desired UIActivityIndicatorViewStyle
 *
 *  @param style The style of the UIActivityIndicatorView
 */
- (void)setIndicatorStyle:(UIActivityIndicatorViewStyle)style;
Piyush
  • 1,534
  • 12
  • 32
  • what is the difference from my code ?? I copied and pasted your code then realized it is same, and throwing the same error. – Abhishek Mitra Jun 01 '17 at 10:05
  • `[cell.cellImgView sd_setShowActivityIndicatorView:YES]; [cell.cellImgView sd_setIndicatorStyle:UIActivityIndicatorViewStyleGray];` And and answer `[cell.cellImgView setShowActivityIndicatorView:YES]; [cell.cellImgView setIndicatorStyle:UIActivityIndicatorViewStyleGray];` both are same ? – Piyush Jun 01 '17 at 10:08
  • No, My mistake, did that and now it can mapped to `UIImageView+WebCache.h` class, if I press cmd and on method name, but error is not going, i cleaned several times but during build errors come again. – Abhishek Mitra Jun 01 '17 at 10:10
  • This methods are in `#import "UIView+WebCache.h"` by importing such file in my desired class and installing the sdwebimage by pods, its started working. Thanks anyway, I appreciate your time for me. – Abhishek Mitra Jun 01 '17 at 10:21
1

Import following file

#import "UIImageView+WebCache.h"

#import "UIImageView+UIActivityIndicatorForSDWebImage.h"
KKRocks
  • 8,222
  • 1
  • 18
  • 84
  • or import another UIIMageVIew category file which are consists this method. – KKRocks Jun 01 '17 at 08:37
  • how to do that? – Abhishek Mitra Jun 01 '17 at 08:38
  • try to import UIImageView+UIActivityIndicatorForSDWebImage.h file ....if exist in your project – KKRocks Jun 01 '17 at 08:40
  • is this file exist in your project : "UIImageView+WebCache.h" ? – KKRocks Jun 01 '17 at 08:42
  • No there is no such file, but i downloaded it from this link https://github.com/JJSaccolo/UIActivityIndicator-for-SDWebImage and integrated, then did `#import "UIImageView+UIActivityIndicatorForSDWebImage.h"` though it is not working. And yes `UIImageView+WebCache.h` this file is available .. – Abhishek Mitra Jun 01 '17 at 08:45
  • then it will working this file because this method declared on this class. – KKRocks Jun 01 '17 at 08:46
  • then import this file UIImageView+UIActivityIndicatorForSDWebImage.h – KKRocks Jun 01 '17 at 08:47
  • Look these all files are there https://ibb.co/eRVK8F and I'm using it in pods, and from this link github.com/rs/SDWebImage , i got the idea to attach such indicator. – Abhishek Mitra Jun 01 '17 at 08:52
  • `#import ` This throwing error , despite that, `#import "UIImageView+UIActivityIndicatorForSDWebImage.h"` it is not throwing error. – Abhishek Mitra Jun 01 '17 at 09:00
  • yes it is but i mentioned because user can understand this sp – KKRocks Jun 01 '17 at 09:02
  • I uninstall it from pod and manually dragged and dropped it into the project, everything seems is okay but same result for that `sd_setShowActivityIndicatorView` and `sd_setIndicatorStyle` :/ – Abhishek Mitra Jun 01 '17 at 09:19
  • try to clean project . – KKRocks Jun 01 '17 at 09:31
  • @KKRocks `sd_setImageWithURL` is accessed that means there is nothing wrong with importing the `SDWebImage` – Piyush Jun 01 '17 at 10:04
  • I figured it out @KKRocks, By importing `#import "UIView+WebCache.h"` and installing `SDWebImage` in pods, it started working. Gone those errors. Thanks for your time, I appreciate you for helping me in so many ways. And please upvote my answer it is working now. – Abhishek Mitra Jun 01 '17 at 10:23
  • @KKRocks I did.. and happy coding :) – Abhishek Mitra Jun 01 '17 at 10:33