SLComposeViewController appears slowly

SLComposeViewController takes 3-4 seconds after it is submitted. But the loop completion method presentViewController:(UIViewController *) animated:(BOOL) completion:^(void)completion calls the call. Therefore, even if I use the download indicator, it instantly disappears. The corresponding code is given below. Btw I tried dispatch_async , this did not 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]; }]; 
+3
source share
1 answer

So this is not a fix, but it may help you. I couldn't make things appear faster, I think this is just an implementation that retrieves data before displaying.

Since the currentViewController completes almost instantly, my workaround was to display a progress view and set the selector to execute after 2 seconds. The selector simply hides the idea of ​​progress, here is 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]; } 
0
source

Source: https://habr.com/ru/post/1447820/


All Articles