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

[TIMOB-11295] Fix button auto and undefined behavior #3126

Merged
merged 1 commit into from
Oct 8, 2012
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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