I have a UIViewController with a UITableView in it. I add a UIView as a subview on top of that. When I press one of the UIButtons on the subview, there is a noticeable lag. How do I make it faster?
See video: http://www.youtube.com/watch?v=KWy6NrZUeqA&feature=youtu.be
- (IBAction)tweetThat:(id)sender {
[MBProgressHUD showHUDAddedTo:self.socialMediaView animated:YES];
dispatch_queue_t queueOne=dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
dispatch_sync(queueOne, ^{
NSString *tweetBody=@"BLABLABLATweet";
if ([TWTweetComposeViewController canSendTweet])
{
TWTweetComposeViewController *tweetSheet =
[[TWTweetComposeViewController alloc] init];
[tweetSheet setInitialText:tweetBody];
dispatch_async(dispatch_get_main_queue(), ^{
[MBProgressHUD hideHUDForView:self.controllerView animated:YES];
[self presentModalViewController:tweetSheet animated:YES];
});
}
});
}
change your dispatch_sync to dispatch_async. what is the point of dispatching to the background if you are going to lock up the UI until it returns.