【发布时间】:2016-08-16 07:04:20
【问题描述】:
SLComposeViewController 在呈现后需要 3-4 秒才会出现。但是presentViewController:(UIViewController *) animated:(BOOL) completion:^(void)completion 方法完成块会立即被调用。因此,即使我使用加载指示器,它也会在眨眼间消失。相关代码如下。顺便说一句,我试过 dispatch_async 没用。
我怎样才能加快这个过程你有什么想法吗?
SLComposeViewController *shareView = [SLComposeViewController composeViewControllerForServiceType: SLServiceTypeFacebook];
[shareView setTitle:@"Title"];
[shareView setInitialText:@"Description"];
[shareView addURL:[NSURL URLWithString:@"http://www.google.com/"]];
[shareView setCompletionHandler:^(SLComposeViewControllerResult result) {
switch (result) {
case SLComposeViewControllerResultCancelled:
{
NSLog(@"Facebook Post Canceled");
break;
}
case SLComposeViewControllerResultDone:
{
NSLog(@"Facebook Post Successful");
break;
}
default:
break;
}
}];
UIActivityIndicatorView *activityView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
activityView.center = CGPointMake([UIScreen mainScreen].bounds.size.width / 2.0, [UIScreen mainScreen].bounds.size.height / 2.0);
[activityView startAnimating];
[self.view addSubview:activityView];
[self presentViewController:shareView animated:YES completion:^{
NSLog(@"Presented facebook");
[activityView removeFromSuperview];
}];
【问题讨论】:
-
是的,我已经检查过了。我发布了一个新问题,因为我还想问为什么完成块返回但视图显示速度没有那么快。
-
您找到可行的解决方案了吗?
-
@BoilingLime 不,我不能让它看起来很快。所以我放了一个像 Android Toast 这样的动画文本,说“共享屏幕正在打开”1 秒钟。
标签: ios objective-c slcomposeviewcontroller