SLComposeViewController缓慢显示 [英] SLComposeViewController appears slowly

查看:114
本文介绍了SLComposeViewController缓慢显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

SLComposeViewController 呈现后需要3-4秒才能显示。但 presentViewController :( UIViewController *)动画:(BOOL)完成:^(void)完成方法立即调用完成块。因此,即使我使用加载指示器,它也会在眨眼间消失。相关代码如下。顺便说一句,我试过 dispatch_async 它没有用。

SLComposeViewController takes 3-4 seconds to appear after presenting it. But presentViewController:(UIViewController *) animated:(BOOL) completion:^(void)completion methods completion block gets called immediately. So even if I use a loading indicator it disappears in a blink. The related code is below. Btw I tried dispatch_async it didn't work.

如果你有任何想法,我怎样才能加快这个过程?

How can I speed up the process do you have any ideas?

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


推荐答案

所以,这不是修复,但它可能会帮助你。我无法让事情看起来更快,我认为它只是在显示自身之前拉入数据的实现。

So, this isn't a fix, but it might help you out. I couldn't get the thing to appear faster, I think its just the implementation pulling in data before displaying itself.

由于nowViewController完成几乎立即执行,我的解决方法是显示进度视图,并设置选择器在2秒后执行。选择器只是隐藏进度视图,这是一个例子。

Since the presentViewController completion executes almost instantly, my workaround was to display a progress view, and set a selector to execute after 2 seconds. The selector simply hides the progress view, here's an example.

[MBProgressHUD showHUDAddedTo:self.view animated:YES];
[self performSelector:@selector(hideProgressView) withObject:nil afterDelay:2.0f];

[self presentViewController:self.composeViewController animated:YES completion:nil];


- (void)hideProgressView
{
    [MBProgressHUD hideHUDForView:self.view animated:YES];
}

这篇关于SLComposeViewController缓慢显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆