diff --git a/examples/component/input-demo.we b/examples/component/input-demo.we index ed529841f8..7056218d0c 100644 --- a/examples/component/input-demo.we +++ b/examples/component/input-demo.we @@ -136,4 +136,4 @@ } } }; - \ No newline at end of file + diff --git a/examples/component/web-demo.we b/examples/component/web-demo.we index 62cc209f08..2be930c75d 100644 --- a/examples/component/web-demo.we +++ b/examples/component/web-demo.we @@ -46,7 +46,6 @@ module.exports = { methods: { goback: function() { - var $webview = require('@weex-module/webview'); var webElement = this.$el('webview'); $webview.goBack(webElement.ref); }, diff --git a/examples/module/stream-demo.we b/examples/module/stream-demo.we index d52c1b0fe8..e1817c8383 100644 --- a/examples/module/stream-demo.we +++ b/examples/module/stream-demo.we @@ -91,7 +91,8 @@ stream.fetch({ method: 'POST', url: POST_URL, - type:'json' + type:'json', + body:JSON.stringify({username:'weex'})//or you can just use JSON Object {username:'weex'} }, function(ret) { if(!ret.ok){ me.postResult = "request failed"; diff --git a/ios/sdk/WeexSDK/Sources/Component/WXEmbedComponent.m b/ios/sdk/WeexSDK/Sources/Component/WXEmbedComponent.m index 1d47b4d3a5..3b1df98888 100644 --- a/ios/sdk/WeexSDK/Sources/Component/WXEmbedComponent.m +++ b/ios/sdk/WeexSDK/Sources/Component/WXEmbedComponent.m @@ -151,16 +151,18 @@ - (void)_renderWithURL:(NSURL *)sourceURL }; _embedInstance.onFailed = ^(NSError *error) { - if (weakSelf.errorView) { - return ; - } - - WXErrorView *errorView = [[WXErrorView alloc]initWithFrame:CGRectMake(0.0f, 0.0f, 135.0f, 130.0f)]; - errorView.center = CGPointMake(weakSelf.view.bounds.size.width / 2.0f, weakSelf.view.bounds.size.height / 2.0f); - errorView.delegate = weakSelf; - [weakSelf.view addSubview:errorView]; - - weakSelf.errorView = errorView; + dispatch_async(dispatch_get_main_queue(), ^{ + if (weakSelf.errorView) { + return ; + } + + WXErrorView *errorView = [[WXErrorView alloc]initWithFrame:CGRectMake(0.0f, 0.0f, 135.0f, 130.0f)]; + errorView.center = CGPointMake(weakSelf.view.bounds.size.width / 2.0f, weakSelf.view.bounds.size.height / 2.0f); + errorView.delegate = weakSelf; + [weakSelf.view addSubview:errorView]; + + weakSelf.errorView = errorView; + }); }; _embedInstance.renderFinish = ^(UIView *view) { diff --git a/ios/sdk/WeexSDK/Sources/Component/WXImageComponent.m b/ios/sdk/WeexSDK/Sources/Component/WXImageComponent.m index 6baac1d9a7..9cc33842c2 100644 --- a/ios/sdk/WeexSDK/Sources/Component/WXImageComponent.m +++ b/ios/sdk/WeexSDK/Sources/Component/WXImageComponent.m @@ -110,7 +110,7 @@ - (void)updateAttributes:(NSDictionary *)attributes _imageSrc = [[WXConvert NSString:attributes[@"src"]] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; [self updateImage]; } - + [self configPlaceHolder:attributes]; if (attributes[@"resize"]) { diff --git a/ios/sdk/WeexSDK/Sources/Component/WXScrollerComponent.m b/ios/sdk/WeexSDK/Sources/Component/WXScrollerComponent.m index 7a728839d0..bcec5a7dc1 100644 --- a/ios/sdk/WeexSDK/Sources/Component/WXScrollerComponent.m +++ b/ios/sdk/WeexSDK/Sources/Component/WXScrollerComponent.m @@ -215,7 +215,7 @@ - (void)adjustSticky } CGFloat scrollOffsetY = ((UIScrollView *)self.view).contentOffset.y; for(WXComponent *component in self.stickyArray) { - if (CGPointEqualToPoint(component->_absolutePosition, CGPointZero)) { + if (isnan(component->_absolutePosition.x) && isnan(component->_absolutePosition.y)) { component->_absolutePosition = [component.supercomponent.view convertPoint:component.view.frame.origin toView:self.view]; } CGPoint relativePosition = component->_absolutePosition; diff --git a/ios/sdk/WeexSDK/Sources/Component/WXSliderNeighborComponent.m b/ios/sdk/WeexSDK/Sources/Component/WXSliderNeighborComponent.m index b3ec0de313..98fc5d4713 100644 --- a/ios/sdk/WeexSDK/Sources/Component/WXSliderNeighborComponent.m +++ b/ios/sdk/WeexSDK/Sources/Component/WXSliderNeighborComponent.m @@ -514,6 +514,23 @@ - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gesture shouldReceiveTouch:(UIT return YES; } +- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer{ + //if the view which the otherGestureRecognizer works on is a scrollview and also it is scrollEnabled vertically ,at this time,we should not block the guesture from being recognized by the otherGestureRecognize + if ([gestureRecognizer isKindOfClass:[UIPanGestureRecognizer class]] && [otherGestureRecognizer isKindOfClass:[UIPanGestureRecognizer class]]) { + if ([otherGestureRecognizer.view isKindOfClass:[UIScrollView class]]) { + UIScrollView* scrollview = (UIScrollView *)otherGestureRecognizer.view; + if (scrollview.scrollEnabled) { + UIPanGestureRecognizer* panRcgn= (UIPanGestureRecognizer *)gestureRecognizer; + //check offset for confirming vertival movement + if (fabs([panRcgn translationInView:panRcgn.view].y) > fabs([panRcgn translationInView:panRcgn.view].x)*16) { + return YES; + } + } + } + } + return NO; +} + - (void)didPan:(UIPanGestureRecognizer *)panGesture { @@ -526,11 +543,12 @@ - (void)didPan:(UIPanGestureRecognizer *)panGesture _scrolling = NO; _decelerating = NO; _previousTranslation = _vertical? [panGesture translationInView:self].y: [panGesture translationInView:self].x; - + [_delegate sliderNeighborWillBeginDragging:self]; break; } case UIGestureRecognizerStateEnded: + case UIGestureRecognizerStateCancelled: case UIGestureRecognizerStateFailed: { @@ -566,6 +584,7 @@ - (void)didPan:(UIPanGestureRecognizer *)panGesture } case UIGestureRecognizerStateChanged: { + CGFloat translation = _vertical? [panGesture translationInView:self].y: [panGesture translationInView:self].x; CGFloat velocity = _vertical? [panGesture velocityInView:self].y: [panGesture velocityInView:self].x; @@ -1425,6 +1444,22 @@ - (UIView *)loadView return _sliderView; } +- (void)dealloc +{ + _sliderView.delegate = nil; + _sliderView.dataSource = nil; + if (_autoPlay) { + [self _stopAutoPlayTimer]; + } + _sliderView = nil; + [self.items removeAllObjects]; +} + +- (void)viewDidUnload +{ + [self.items removeAllObjects]; +} + - (void)viewDidLoad { _sliderView = (WXSliderNeighborView *)self.view; diff --git a/ios/sdk/WeexSDK/Sources/Events/WXComponent+Events.m b/ios/sdk/WeexSDK/Sources/Events/WXComponent+Events.m index 501d7e0b3a..8d1ee670d4 100644 --- a/ios/sdk/WeexSDK/Sources/Events/WXComponent+Events.m +++ b/ios/sdk/WeexSDK/Sources/Events/WXComponent+Events.m @@ -122,8 +122,7 @@ - (void)removeEvent:(NSString *)removeEventName - (void)_initEvents:(NSArray *)events { - NSArray *eventsCopy = [events copy]; - for (NSString *addEventName in eventsCopy) { + for (NSString *addEventName in events) { [self _addEventOnMainThread:addEventName]; } } diff --git a/ios/sdk/WeexSDK/Sources/Manager/WXComponentManager.m b/ios/sdk/WeexSDK/Sources/Manager/WXComponentManager.m index e292c63f23..804e06ebc8 100644 --- a/ios/sdk/WeexSDK/Sources/Manager/WXComponentManager.m +++ b/ios/sdk/WeexSDK/Sources/Manager/WXComponentManager.m @@ -462,7 +462,6 @@ - (void)createFinish WX_MONITOR_SUCCESS(WXMTNativeRender); if(instance.renderFinish){ - [instance creatFinish]; instance.renderFinish(rootView); } }]; diff --git a/ios/sdk/WeexSDK/Sources/Model/WXComponent.m b/ios/sdk/WeexSDK/Sources/Model/WXComponent.m index 8c04d8c03d..b63a61f897 100644 --- a/ios/sdk/WeexSDK/Sources/Model/WXComponent.m +++ b/ios/sdk/WeexSDK/Sources/Model/WXComponent.m @@ -69,9 +69,10 @@ - (instancetype)initWithRef:(NSString *)ref _styles = styles ? [NSMutableDictionary dictionaryWithDictionary:styles] : [NSMutableDictionary dictionary]; _attributes = attributes ? [NSMutableDictionary dictionaryWithDictionary:attributes] : [NSMutableDictionary dictionary]; _events = events ? [NSMutableArray arrayWithArray:events] : [NSMutableArray array]; - _subcomponents = [NSMutableArray array]; + _absolutePosition = CGPointMake(NAN, NAN); + _isNeedJoinLayoutSystem = YES; _isLayoutDirty = YES; _isViewFrameSyncWithCalculated = YES; diff --git a/ios/sdk/WeexSDK/Sources/Module/WXGlobalEventModule.m b/ios/sdk/WeexSDK/Sources/Module/WXGlobalEventModule.m index bd5bbc1bc4..1ae4c600d2 100644 --- a/ios/sdk/WeexSDK/Sources/Module/WXGlobalEventModule.m +++ b/ios/sdk/WeexSDK/Sources/Module/WXGlobalEventModule.m @@ -46,7 +46,7 @@ - (void)removeEventListener:(NSString *)event { if (_eventCallback[event]) { [_eventCallback removeObjectForKey:event]; - [[NSNotificationCenter defaultCenter] removeObserver:self name:event object:weexInstance]; + [[NSNotificationCenter defaultCenter] removeObserver:self name:event object:nil]; } else { WXLogWarning(@"eventName \"%@\" doesn't exist", event); } @@ -70,4 +70,9 @@ - (void)fireGlobalEvent:(NSNotification *)notification } } +- (void)dealloc +{ + [[NSNotificationCenter defaultCenter] removeObserver:self]; +} + @end diff --git a/ios/sdk/WeexSDK/Sources/Module/WXStreamModule.m b/ios/sdk/WeexSDK/Sources/Module/WXStreamModule.m index 594c0d29ba..4b89df73e4 100644 --- a/ios/sdk/WeexSDK/Sources/Module/WXStreamModule.m +++ b/ios/sdk/WeexSDK/Sources/Module/WXStreamModule.m @@ -79,7 +79,6 @@ - (void)fetch:(NSDictionary *)options callback:(WXModuleCallback)callback progre } urlStr = newUrlStr; NSDictionary *headers = [options objectForKey:@"headers"]; - NSString *body = [options objectForKey:@"body"]; NSString *type = [options objectForKey:@"type"]; NSURL *url = [NSURL URLWithString:urlStr]; NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; @@ -95,8 +94,27 @@ - (void)fetch:(NSDictionary *)options callback:(WXModuleCallback)callback progre NSString *value = [headers objectForKey:header]; [request setValue:value forHTTPHeaderField:header]; } - [request setHTTPBody:[body dataUsingEncoding:NSUTF8StringEncoding]]; + if ([options objectForKey:@"body"]) { + NSData * body = nil; + if ([[options objectForKey:@"body"] isKindOfClass:[NSString class]]) { + // compatible with the string body + body = [[options objectForKey:@"body"] dataUsingEncoding:NSUTF8StringEncoding]; + } + if ([[options objectForKey:@"body"] isKindOfClass:[NSDictionary class]]) { + body = [[WXUtility JSONString:[options objectForKey:@"body"]] dataUsingEncoding:NSUTF8StringEncoding]; + } + if (!body) { + [callbackRsp setObject:@(-1) forKey:@"status"]; + [callbackRsp setObject:@false forKey:@"ok"]; + callback(callbackRsp); + + return; + } + + [request setHTTPBody:body]; + } + [callbackRsp setObject:@{ @"OPENED": @1 } forKey:@"readyState"]; progressCallback(callbackRsp, TRUE); diff --git a/ios/sdk/WeexSDK/Sources/Protocol/WXModuleProtocol.h b/ios/sdk/WeexSDK/Sources/Protocol/WXModuleProtocol.h index 327d6d7cd0..1e2528c699 100644 --- a/ios/sdk/WeexSDK/Sources/Protocol/WXModuleProtocol.h +++ b/ios/sdk/WeexSDK/Sources/Protocol/WXModuleProtocol.h @@ -24,7 +24,6 @@ * @discussion callback data to js, the id of callback function will be removed to save memory. */ typedef void (^WXModuleCallback)(id result); -typedef void (^WXModuleKeepAliveCallback)(id result, BOOL keepAlive); /** * @abstract the module callback , result can be string or dictionary.