Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

App Crashes using AsyncImageVew #42

Open
rkoirala opened this issue Jan 19, 2014 · 2 comments
Open

App Crashes using AsyncImageVew #42

rkoirala opened this issue Jan 19, 2014 · 2 comments

Comments

@rkoirala
Copy link

Thanks AsyncImageView is a perfect library for loading images asynchronously .
I have used this library many time but when I use to load many images in paging the app crashes. Its a memory problem I guess.

Here's my piece of code:

self.asyncImageView = [[AsyncImageView alloc]init];
self.asyncImageView.frame = CGRectMake(0, 0, self.bounds.size.width, self.bounds.size.height);
self.asyncImageView.contentMode = UIViewContentModeScaleAspectFit;
self.asyncImageView.imageURL = [NSURL URLWithString: self.imageUrl];
self.asyncImageView.userInteractionEnabled = YES;
[AsyncImageLoader sharedLoader].cache = [AsyncImageLoader defaultCache];

[self addSubview : self.asyncImageView]; 

I have used asyncImage to page many images.

Thanks in advance

@nicklockwood
Copy link
Owner

The code looks OK, although this line is redundant since it's the default anyway:

[AsyncImageLoader sharedLoader].cache = [AsyncImageLoader defaultCache];

Can you post more of the code? - where is this code used exactly? In a table view?

@rkoirala
Copy link
Author

I have used asyncImageView for paging : code is as follows
-(void) showPapers{

NSString *urlString = self.url;

NSArray *imageLinks = [[NSArray alloc] init];
imageLinks = [Utils htmlParsing: urlString];
for (int i = 0; i < imageLinks.count; i++) {

    CGRect frame = [self.view frame];
    frame.origin.x = self.scrollView.frame.size.width * i;
    frame.origin.y = 0;
    frame.size = self.scrollView.frame.size;

    self.zoomView = [[ZoomScrollView alloc] initWithFrame:frame];
    self.zoomView.frame = frame;
    self.zoomView.navigationController = self.navigationController;

    self.zoomView.imageUrl = [imageLinks objectAtIndex: i];
    [self.zoomView initImageView];

    [self.scrollView addSubview: self.zoomView];
}
self.scrollView.contentSize = CGSizeMake(self.scrollView.frame.size.width * imageLinks.count, self.scrollView.frame.size.height);

}

2.Code for ZoomScrollView is as follows:

  • (void)initImageView
    {

    //self.imageUrl = [[NSString alloc] init];
    self.tag = IMAGE_VIEW_TAG;
    self.asyncImageView = [[AsyncImageView alloc]init];
    self.asyncImageView.frame = CGRectMake(0, 0, self.bounds.size.width, self.bounds.size.height);
    self.asyncImageView.contentMode = UIViewContentModeScaleAspectFit;
    self.asyncImageView.imageURL = [NSURL URLWithString: self.imageUrl];
    self.asyncImageView.userInteractionEnabled = YES;
    [AsyncImageLoader sharedLoader].cache = [AsyncImageLoader defaultCache];

    //get image view
    AsyncImageView *aImgeView = (AsyncImageView *)[self viewWithTag:IMAGE_VIEW_TAG];

    //cancel loading previous image for cell
    [[AsyncImageLoader sharedLoader] cancelLoadingImagesForTarget : aImgeView];

    [self addSubview : self.asyncImageView];

    // Add gesture,double tap zoom imageView.
    UITapGestureRecognizer *doubleTapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self
    action:@selector(handleDoubleTap:)];
    [doubleTapGesture setNumberOfTapsRequired:2];
    [self.asyncImageView addGestureRecognizer:doubleTapGesture];

    float minimumScale = self.frame.size.width / self.asyncImageView.frame.size.width;
    [self setMinimumZoomScale:minimumScale];
    [self setMaximumZoomScale:3.5];
    [self setZoomScale:2.5];
    }

App crashes when I view 5-6 images. Please help me finding a solution.
Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants