在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];
Run Code Online (Sandbox Code Playgroud)
TWTweetComposeViewController在iOS 6.0中已弃用,您需要使用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];
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1642 次 |
| 最近记录: |