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

Scrool Photos, verify if image is downloaded #41

Open
narlei opened this issue Feb 2, 2015 · 0 comments
Open

Scrool Photos, verify if image is downloaded #41

narlei opened this issue Feb 2, 2015 · 0 comments

Comments

@narlei
Copy link

narlei commented Feb 2, 2015

Hello,

In my code, in function "- (void)layoutScrollViewAnimated:(BOOL)animated{" in file "EGOPhotoImageView.m" I add a verification if image exists: "if (self.imageView.image) {" :

  • (void)layoutScrollViewAnimated:(BOOL)animated{
    if (self.imageView.image) {

    if (animated) {
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:0.0001];
    }

    CGFloat hfactor = self.imageView.image.size.width / self.frame.size.width;
    CGFloat vfactor = self.imageView.image.size.height / self.frame.size.height;

    CGFloat factor = MAX(hfactor, vfactor);

    CGFloat newWidth = self.imageView.image.size.width / factor;
    CGFloat newHeight = self.imageView.image.size.height / factor;

    CGFloat leftOffset = (self.frame.size.width - newWidth) / 2;
    CGFloat topOffset = (self.frame.size.height - newHeight) / 2;

    self.scrollView.frame = CGRectMake(leftOffset, topOffset, newWidth, newHeight);
    self.scrollView.layer.position = CGPointMake(self.bounds.size.width/2, self.bounds.size.height/2);
    self.scrollView.contentSize = CGSizeMake(self.scrollView.bounds.size.width, self.scrollView.bounds.size.height);
    self.scrollView.contentOffset = CGPointMake(0.0f, 0.0f);
    self.imageView.frame = self.scrollView.bounds;

    if (animated) {
    [UIView commitAnimations];
    }
    }

}

With this, the code is working very fine.
Can you add this in project because I'm using CocoaPods.

Congratulations for your work!

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

1 participant