Skip to content
This repository has been archived by the owner on Jun 3, 2021. It is now read-only.

Commit

Permalink
[WEEX-241][iOS] add WXVideoComponent "poster" attribute.
Browse files Browse the repository at this point in the history
Lazy load UIImageView property.
  • Loading branch information
xuyouyang committed Mar 8, 2018
1 parent 946bcec commit b0e4455
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions ios/sdk/WeexSDK/Sources/Component/WXVideoComponent.m
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,6 @@ - (id)init
}

[self addSubview:_playerViewController.view];

_posterImageView = [[UIImageView alloc] init];
_posterImageView.userInteractionEnabled = YES;
[_posterImageView addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(posterTapHandler)]];
_posterImageView.hidden = YES;
[self addSubview:_posterImageView];
[self bringSubviewToFront:_posterImageView];
}
return self;
}
Expand Down Expand Up @@ -158,7 +151,6 @@ - (void)setFrame:(CGRect)frame
videoFrame.origin.x = 0;
videoFrame.origin.y = 0;
[_playerViewController.view setFrame:videoFrame];
[_posterImageView setFrame:videoFrame];
}

- (void)setURL:(NSURL *)URL
Expand Down Expand Up @@ -261,6 +253,18 @@ - (void)posterTapHandler {
}
}

- (UIImageView *)posterImageView {
if (!_posterImageView) {
_posterImageView = [[UIImageView alloc] initWithFrame:self.bounds];
_posterImageView.userInteractionEnabled = YES;
[_posterImageView addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(posterTapHandler)]];
_posterImageView.hidden = YES;
[self addSubview:_posterImageView];
[self bringSubviewToFront:_posterImageView];
}
return _posterImageView;
}

- (id<WXImgLoaderProtocol>)imageLoader
{
static id<WXImgLoaderProtocol> imageLoader;
Expand Down

0 comments on commit b0e4455

Please sign in to comment.