1
if ([TWTweetComposeViewController canSendTweet]) {
    // Initialize Tweet Compose View Controller 
TWTweetComposeViewController *vc = [[[TWTweetComposeViewController alloc] init]autorelease];
    // Settin The Initial Text
    [vc setInitialText:status];

    // Setting a Completing Handler
    [vc setCompletionHandler:^(TWTweetComposeViewControllerResult result) {
        if(result == TWTweetComposeViewControllerResultDone) {
                 NSLog(@"Posted ");
        }
    }];     
} else {
    // Show Alert View When The Application Cannot Send Tweets
    NSString *message = @"The application cannot send a tweet at the moment. This is because it cannot reach Twitter or you don't have a Twitter account associated with this device.";
    UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Oops" message:message delegate:nil cancelButtonTitle:@"Dismiss" otherButtonTitles:nil];
    [alertView show];
}

メモリ警告が発生しない限り、コードは正常に機能しますが、デバイスでメモリ警告をシミュレートすると、バグでアプリがクラッシュします。

Terminating app due to uncaught exception 'NSRangeException', reason: 'Cannot remove an observer <TWTweetComposeViewController 0xee2dc80> for the key path "contentSize" from <UITextView 0xee3c5e0> because it is not registered as an observer.'
4

0 に答える 0