After a completed tweet from TWTweetComposeViewController
, my app locks up. Going out to the home screen and coming back seems to fix this, and the clock still ticks, but no touches register to any of my views/controls.
Thinking something weird must be happening in my app, I made a fresh utility-app-template project, linked it w/ Twitter.framework
, and redefined the info UIButton
's IBAction
method to this:
- (IBAction)showInfo:(id)sender
{
TWTweetComposeViewController *twt = [[TWTweetComposeViewController alloc] init];
[twt setInitialText:@"some garbage"];
[twt addURL:[NSURL URLWithString:@"http://google.com"]];
twt.completionHandler = ^(TWTweetComposeViewControllerResult r) { NSLog(@"it happened: %d",r); };
[self presentViewController:twt animated:YES completion:NULL];
[twt release];
}
After canceling (which takes 2 taps, interestingly), it can be brought back up by tapping the 'i', but after submitting, the 'i' is non-responsive until backgrounding the app.
Has anyone used this successfully? Or am I blatantly missing something?
The problem here is that you are presenting a modal view controller (the twitter view controller is modal); however, your completion handler isn't dismissing the modal view controller when finished. This leaves the twitter controller to capture all the touches on the screen preventing your app from functioning properly.
You need to make sure you add [self dismissModalViewControllerAnimated:YES]; to your completion handler.
Something like this:
(IBAction)showInfo:(id)sender
{
TWTweetComposeViewController *twt = [[TWTweetComposeViewController alloc] init];
[twt setInitialText:@"some garbage"];
[twt addURL:[NSURL URLWithString:@"http://google.com"]];
twt.completionHandler = ^(TWTweetComposeViewControllerResult result) {
switch (result) {
case TWTweetComposeViewControllerResultCancelled:
break;
case TWTweetComposeViewControllerResultDone:
break;
default:
break;
}
[self dismissModalViewControllerAnimated:YES];
};
[self presentModalViewController:twt animated:YES];
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With