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];
}];