Skip to content

Commit

Permalink
Merge pull request #3126 from vishalduggal/timob-11295
Browse files Browse the repository at this point in the history
[TIMOB-11295] Fix button auto and undefined behavior
  • Loading branch information
srahim committed Oct 8, 2012
2 parents eac256b + 19eea7b commit d4cdc7e
Showing 1 changed file with 2 additions and 23 deletions.
25 changes: 2 additions & 23 deletions iphone/Classes/TiUIButton.m
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ -(void)updateBackgroundImage
{
CGRect bounds = [self bounds];
[button setFrame:bounds];
if ((backgroundImageCache == nil) || CGSizeEqualToSize(bounds.size, CGSizeZero)) {
if ((backgroundImageCache == nil) || (bounds.size.width == 0) || (bounds.size.height == 0)) {
[button setBackgroundImage:nil forState:UIControlStateNormal];
return;
}
Expand Down Expand Up @@ -207,28 +207,7 @@ -(void)setImage_:(id)value
if (image!=nil)
{
[[self button] setImage:image forState:UIControlStateNormal];

// if the layout is undefined or auto, we need to take the size of the image
//TODO: Refactor. This will cause problems if there's multiple setImages called,
//Since we change the values of the proxy.
LayoutConstraint *layoutProperties = [(TiViewProxy *)[self proxy] layoutProperties];
BOOL reposition = NO;

if (TiDimensionIsUndefined(layoutProperties->width) || TiDimensionIsAuto(layoutProperties->width))
{
layoutProperties->width.value = image.size.width;
layoutProperties->width.type = TiDimensionTypeDip;
reposition = YES;
}
if (TiDimensionIsUndefined(layoutProperties->height) || TiDimensionIsAuto(layoutProperties->height))
{
layoutProperties->height.value = image.size.height;
layoutProperties->height.type = TiDimensionTypeDip;
}
if (reposition)
{
[(TiViewProxy *)[self proxy] contentsWillChange];
}
[(TiViewProxy *)[self proxy] contentsWillChange];
}
else
{
Expand Down

0 comments on commit d4cdc7e

Please sign in to comment.