Skip to content

Commit b366950

Browse files
committed
Merge pull request #15 from sitefinitysteve/master
Fix null image index issue
2 parents e90de48 + 4995f6c commit b366950

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

fab.ios.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,17 +110,14 @@ function onIconPropertyChanged(data) {
110110
var icon = data.newValue;
111111
var iconDrawable = null;
112112

113-
//Kill the old Image, cocoapod doesn't support changing it yet
114-
var button = fab.ios.subviews[0];
115-
var oldBadImageView = button.subviews[0];
116-
oldBadImageView.removeFromSuperview();
113+
117114
var newImageView = null;
118115

119116
if(ImageSource.isFileOrResourcePath(icon)){
120117
iconDrawable = ImageSource.fromFileOrResource(icon);
121118

122119
//Set the new one
123-
if (iconDrawable) {
120+
if (iconDrawable !== null) {
124121
newImageView = UIImageView.alloc().initWithImage(iconDrawable.ios);
125122
}
126123
}else{
@@ -130,8 +127,16 @@ function onIconPropertyChanged(data) {
130127
newImageView.frame = CGRectMake(0, 0, 40, 40); //resize
131128

132129
}
130+
131+
if(newImageView !== null){
132+
//Kill the old Image, cocoapod doesn't support changing it yet
133+
var button = fab.ios.subviews[0];
134+
var oldBadImageView = button.subviews[0];
135+
oldBadImageView.removeFromSuperview();
133136

134-
button.addSubview(newImageView);
137+
//Add the new guy
138+
button.addSubview(newImageView);
139+
}
135140
}
136141
common.Fab.iconProperty.metadata.onSetNativeValue = onIconPropertyChanged;
137142

0 commit comments

Comments
 (0)