Committed by
GitHub
Merge pull request #2043 from dreampiggy/set_uibutton_placeholder_if_url_is_nil
Set UIButton's placeholer-image even if the url is nil
Showing
1 changed file
with
4 additions
and
6 deletions
@@ -71,10 +71,9 @@ static inline NSString * backgroundImageURLKeyForState(UIControlState state) { | @@ -71,10 +71,9 @@ static inline NSString * backgroundImageURLKeyForState(UIControlState state) { | ||
71 | completed:(nullable SDExternalCompletionBlock)completedBlock { | 71 | completed:(nullable SDExternalCompletionBlock)completedBlock { |
72 | if (!url) { | 72 | if (!url) { |
73 | [self.imageURLStorage removeObjectForKey:imageURLKeyForState(state)]; | 73 | [self.imageURLStorage removeObjectForKey:imageURLKeyForState(state)]; |
74 | - return; | ||
75 | - } | ||
76 | - | 74 | + } else { |
77 | self.imageURLStorage[imageURLKeyForState(state)] = url; | 75 | self.imageURLStorage[imageURLKeyForState(state)] = url; |
76 | + } | ||
78 | 77 | ||
79 | __weak typeof(self)weakSelf = self; | 78 | __weak typeof(self)weakSelf = self; |
80 | [self sd_internalSetImageWithURL:url | 79 | [self sd_internalSetImageWithURL:url |
@@ -131,10 +130,9 @@ static inline NSString * backgroundImageURLKeyForState(UIControlState state) { | @@ -131,10 +130,9 @@ static inline NSString * backgroundImageURLKeyForState(UIControlState state) { | ||
131 | completed:(nullable SDExternalCompletionBlock)completedBlock { | 130 | completed:(nullable SDExternalCompletionBlock)completedBlock { |
132 | if (!url) { | 131 | if (!url) { |
133 | [self.imageURLStorage removeObjectForKey:backgroundImageURLKeyForState(state)]; | 132 | [self.imageURLStorage removeObjectForKey:backgroundImageURLKeyForState(state)]; |
134 | - return; | ||
135 | - } | ||
136 | - | 133 | + } else { |
137 | self.imageURLStorage[backgroundImageURLKeyForState(state)] = url; | 134 | self.imageURLStorage[backgroundImageURLKeyForState(state)] = url; |
135 | + } | ||
138 | 136 | ||
139 | __weak typeof(self)weakSelf = self; | 137 | __weak typeof(self)weakSelf = self; |
140 | [self sd_internalSetImageWithURL:url | 138 | [self sd_internalSetImageWithURL:url |
-
Please register or login to post a comment