我正在尝试设置一个推文按钮。我所有的代码似乎都在工作,除了它给了我错误“选择器'canSendTweet'没有已知的类方法”有什么建议吗?
- (IBAction)tweetTapped:(id)sender
{
//Check if the device can send tweets
if ([SLComposeViewController canSendTweet])
{
//Create tweet sheet and set initial text
SLComposeViewController *tweetSheet =
[[SLComposeViewController alloc] init];
[tweetSheet setInitialText:@"this is a tweet from my app"];
[tweetSheet addURL:[NSURL URLWithString:@"http://www.iosdeveloperguide.com"]];
//show tweet sheet
[self presentViewController:tweetSheet animated:YES completion:nil];
}
else
{
//Device can not tweet. Show error Notification.
UIAlertView *alertview = [[UIAlertView alloc]
initWithTitle:@"Unable to Tweet"
message:@"Please ensure that you have at least one Twitter account setup and have internet connectivity"
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alertview show];
}
}
@end