Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS 5: Twitter composer view appears slowly

I have a question about presenting the TWTweetComposerViewController as a modal view in iOS 5.

I use the apple sample code as below to implement a tweet method in my app.

-(void)tweet
{
    //Using tweeting example code.

    //Setup the build-in twitter composer view controller
    TWTweetComposeViewController *tweetViewController = [[TWTweetComposeViewController alloc]init];

    //Add url
    [tweetViewController addURL:[self URL]];
    [tweetViewController setInitialText:@""];

    //Present Composer
    [self presentModalViewController:tweetViewController animated:YES];

    //Creat the completion handler
    [tweetViewController setCompletionHandler:^(TWTweetComposeViewControllerResult result)
    {
         //Do something here.

         [self dismissModalViewControllerAnimated:YES];
     }];
    [tweetViewController release];
}

This works fine, when I call the tweet method, the tweet controller does appear as a modal view.

However, the problem is: the composer shows up very slowly. It usually takes 3-5 seconds to show the composer. Of course, this is when the app calls this method for the first time. After the first time, it shows up a little bit quicker, but still take about 1~2 seconds.

I wonder if is there something I didn't do right to make the composer view appear slowly? Is there any way to speed up the process?

Btw. the testing device is the iPhone 4.

Thanks!

like image 287
Jing Avatar asked Feb 02 '12 01:02

Jing


1 Answers

Yes, there is. You can preload the class by initializing it in the background sometime before you'll ever need it. Move tweetViewController into an instance or static variable, initialize and set all of its properties. Then just show it in the tweet method.

like image 190
james_womack Avatar answered Oct 04 '22 16:10

james_womack