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