3

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];
}];
mkeremkeskin
  • 644
  • 10
  • 27
  • have you checked this http://stackoverflow.com/questions/13519904/how-to-make-the-presentviewcontroller-with-slcomposeviewcontroller-faster – Vizllx May 08 '15 at 13:09
  • Yup I've checked it. I posted a new question because I want to ask also why completion blocks returns but the view doesn't appear as fast as it is. – mkeremkeskin May 08 '15 at 13:15
  • Did you find a working solution? – BoilingLime Oct 22 '15 at 11:55
  • @BoilingLime No I couldn't make it appear fast. So I put a animated text like Android toast saying "Share screen is opening" for 1 second. – mkeremkeskin Oct 22 '15 at 12:22

1 Answers1

0

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.

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];
}
nenchev
  • 1,998
  • 28
  • 16