1
** Twitter.framework 및 Accounts.framework를 추가했습니다.iOS 5.0의 Twitter 통합
그리고 Twitter.h 헤더 파일을 가져 왔습니다.
하지만 ** 오류 "선언되지 않은 식별자 'tweetSheet'의 사용"을 얻고있다
Class TWTweetComposeViewController = NSClassFromString(@"TWTweetComposeViewController");
if(TWTweetComposeViewController != nil) {
//For iOS 5.0 onwards
if ([TWTweetComposeViewController canSendTweet]) {
//Create the tweet sheet
TWTweetComposeViewController *tweetSheet = [[TWTweetComposeViewController alloc] init];
//Customize the tweet sheet here
//Add a tweet message
[tweetSheet setInitialText:[[self getShareContent] objectForKey:@"twitterContent"]];
//Set a blocking handler for the tweet sheet
tweetSheet.completionHandler = ^(TWTweetComposeViewControllerResult result){
if (TWTweetComposeViewControllerResultDone) {
UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:@"Tweeted"
message:@"You successfully tweeted"
delegate:self cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alertView show];
[alertView release];
} else if (TWTweetComposeViewControllerResultCancelled) {
UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:@"Ooops..."
message:@"Something went wrong, try again later"
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alertView show];
[alertView release];
}
[self dismissModalViewControllerAnimated:YES];
};
//Show the tweet sheet!
[self presentModalViewController:tweetSheet animated:YES];
} else {
UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:nil
message:@"You need to configure your Twitter account in the Settings"
delegate:self cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alertView show];
[alertView release];
}
}
[여기] (http://dummycode.com/b/3)는 Twitter API와 iOS를 통합 한 훌륭한 글입니다. –