5

Since the iOS 7.1 beta 5, I have a strange bug with my little plugin : link

My plugin is a subclass of UIImageView, inside of this class I have an another UIImageView called img.

I have rewrite the setter and getter of image :

- (void)setImage:(UIImage *)image{

    self.img.image = image;

}

- (UIImage *)image{

    return _img.image;

}

So NSLog(@"%@",self.image) return _img.image, I'm ok.

NSLog(@"%@",[super image]) return (null), I'm ok.

The problem is with iOS 7.0 self don't display an image, but with iOS 7.1 self display _img.image.

Visually, I don't want a image for self, I want the same behavior than iOS 7.0.

So I try a another thing to understand, if I use this setter/getter :

- (void)setImage:(UIImage *)image{

    [super setImage:[UIImage imageNamed:@"becomeapanda_tumblr_com_portrait"]];

}

- (UIImage *)image{

    return [UIImage imageNamed:@"becomeapanda_tumblr_com"];

}

With iOS 7.0, self display this image "becomeapanda_tumblr_com_portrait" but with iOS 7.1 self display this image "becomeapanda_tumblr_com".

If I can have any help to understand why with iOS 7.1 my plugin don't have the same behavior, this could be nice!

VivienCormier
  • 1,133
  • 1
  • 11
  • 16
  • Sounds to me like the internal implementation was referencing the image ivar directly in iOS 7.0 and now in iOS7.1 it's using the property getter. – Timothy Moose Mar 14 '14 at 09:17
  • Yes I'm ok with you, but it's a huge modification. I have read the iOS 7.1 Apple's docs and there is nothing about this. – VivienCormier Mar 14 '14 at 09:40
  • Apple doesn't document their internal implementations. – Timothy Moose Mar 14 '14 at 09:41
  • 1
    You'd probably need to do something like [this](http://stackoverflow.com/questions/1451342/objective-c-find-caller-of-method) to see who's calling the getter and return `nil` if it's `self` calling. – Timothy Moose Mar 14 '14 at 09:45

1 Answers1

-1

Hi Try it out you forgot [self animaticToScaleAspectFit] to put into your method,

    - (void)animateToScaleAspectFitToFrame:(CGRect)frame WithDuration:(float)duration afterDelay:(float)delay{

    if (![self uiimageIsEmpty]) {
        [self initToScaleAspectFitToFrame:frame];

        [UIView animateWithDuration:duration delay:delay options:UIViewAnimationOptionAllowUserInteraction
                         animations:^{
                             [self animaticToScaleAspectFit];
                         } completion:nil];
    }else{
        [self animaticToScaleAspectFit];
        NSLog(@"ERROR, UIImageView %@ don't have UIImage",self);
    }  
}
Chigs79
  • 162
  • 4