I am opening the Twitter compose view on my app, but the screen takes too long to be displayed!
I started using the following code when the user taps the twitter but
I had the same issue -- it was driving me crazy. I fixed it by dispatch_async on the main queue
// Perform this on the main queue
__weak __typeof(self) weakSelf = self;
dispatch_async(dispatch_get_main_queue(), ^{
__strong __typeof(self) strongLocalSelf = weakSelf;
SLComposeViewController *controller = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
[controller setInitialText:@"Share message"];
[controller addURL:@"http://www.someURL.com"];
[strongLocalSelf presentViewController:controller animated:NO completion:nil];
});
This issue has been bugging me as well for a whole day! Finally i get some trick to make the SLComposeViewController appear faster. Its seems when I want to load the SLComposeVC for the first time, The SLComposer will take a lot of resource in main thread, but after that, its will appear perfectly normal without delay... so I guess maybe we need to load the SLCompose View in our view controller (just load the view) and viola.. the SLComposerView will be directly presented into the view...
Just add this code in your appdelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{ ....
//loading the view...make twitter share dialog appear with no dellay
if(NSClassFromString(@"SLComposeViewController") != nil){
SLComposeViewController *composeViewController = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];
[composeViewController view];
}
...
}