You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by ac...@apache.org on 2017/05/11 06:04:20 UTC

[4/5] incubator-weex git commit: * [ios] test for delegate respond to selector

* [ios] test for delegate respond to selector


Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/8d47a27d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/8d47a27d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/8d47a27d

Branch: refs/heads/0.13-dev
Commit: 8d47a27dccb240178c8c285f99ee96dad8e760a4
Parents: 5bba7d8
Author: acton393 <zh...@gmail.com>
Authored: Wed May 10 15:04:10 2017 +0800
Committer: acton393 <zh...@gmail.com>
Committed: Wed May 10 15:04:10 2017 +0800

----------------------------------------------------------------------
 .../WeexSDK/Sources/Component/WXSliderNeighborComponent.m   | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/8d47a27d/ios/sdk/WeexSDK/Sources/Component/WXSliderNeighborComponent.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Component/WXSliderNeighborComponent.m b/ios/sdk/WeexSDK/Sources/Component/WXSliderNeighborComponent.m
index 17bcda3..809facd 100644
--- a/ios/sdk/WeexSDK/Sources/Component/WXSliderNeighborComponent.m
+++ b/ios/sdk/WeexSDK/Sources/Component/WXSliderNeighborComponent.m
@@ -432,7 +432,10 @@ NSComparisonResult sliderNeighorCompareViewDepth(UIView *view1, UIView *view2, W
 
 - (CGFloat)valueForOption:(WXSliderNeighborOption)option withDefault:(CGFloat)value
 {
-    return _delegate? [_delegate sliderNeighbor:self valueForOption:option withDefault:value]: value;
+    if (_delegate && [_delegate respondsToSelector:@selector(sliderNeighbor:valueForOption:withDefault:)]) {
+        return [_delegate sliderNeighbor:self valueForOption:option withDefault:value];
+    }
+    return value;
 }
 
 #pragma mark -
@@ -665,7 +668,9 @@ NSComparisonResult sliderNeighorCompareViewDepth(UIView *view1, UIView *view2, W
     //get number of items and placeholders
     _numberOfVisibleItems = 0;
     _numberOfItems = [_dataSource numberOfItemsInSliderNeighbor:self];
-    _numberOfPlaceholders = [_dataSource numberOfPlaceholdersInsliderNeighbor:self];
+    if ([_dataSource respondsToSelector:@selector(numberOfPlaceholdersInsliderNeighbor:)]) {
+        _numberOfPlaceholders = [_dataSource numberOfPlaceholdersInsliderNeighbor:self];
+    }
     
     //reset view pools
     self.itemViews = [NSMutableDictionary dictionary];