在ios7中,我可以显示No Twitter Accounts Alert,但它在ios7以下版本中完美运行
以下是我的源代码。
TWTweetComposeViewController *viewController = [[TWTweetComposeViewController alloc] init];
//hide the tweet screen
viewController.view.hidden = YES;
// viewController.view.backgroundColor=[UIColor clearColor];
// viewController.view.opaque=NO;
//fire tweetComposeView to show "No Twitter Accounts" alert view on iOS5.1
viewController.completionHandler = ^(TWTweetComposeViewControllerResult result) {
if (result == TWTweetComposeViewControllerResultCancelled) {
[self dismissModalViewControllerAnimated:NO];
}
};
[self presentModalViewController:viewController animated:NO];
//hide the keyboard
[viewController.view endEditing:YES];
答案 0 :(得分:5)
TWTweetComposeViewController
,您需要使用SLComposeViewController
,具体如下:
if([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter]) {
SLComposeViewController *sheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];
SLComposeViewControllerCompletionHandler completionBlock = ^(SLComposeViewControllerResult result){
if (result == SLComposeViewControllerResultCancelled) {
NSLog(@"Cancelled");
} else {
NSLog(@"Done");
}
[sheet dismissViewControllerAnimated:YES completion:Nil];
};
sheet.completionHandler = completionBlock;
//Adding the Text to the post value from iOS
[sheet setInitialText:@"hello twitter"];
[self presentViewController:sheet animated:YES completion:Nil];
}