UIActivityIndicatorView是一个等待指示器(菊花)。
//在.h中声明一个属性:
@property (nonatomic, strong)UIActivityIndicatorView *activityIndicatorView;
//在.m中初始化:
_activityIndicatorView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle: UIActivityIndicatorViewStyleWhiteLarge];
_activityIndicatorView.center = self.view.center;
_activityIndicatorView.autoresizingMask = UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
[self.view addSubview:_activityIndicatorView];
//在需要用的地方:
[_activityIndicatorView startAnimating]; //开始
[_activityIndicatorView stopAnimating]; //停止
UIActivityViewController是苹果自带的分享页面,类似友盟分享,但不需要到第三方平台申请AppKey,直接分享,十分方便。其分享图片需要将图片转为NSData,分享视频只需拿到视频的URL即可。
- (void)shareVideo {
NSURL *URL = [NSURL fileURLWithPath:_assetModel.filePath];
UIActivityViewController *activityVc = [[UIActivityViewController alloc] initWithActivityItems:@[URL] applicationActivities:nil];
[self presentViewController:activityVc animated:YES completion:nil];
}
网友评论