1
我正在創建一個已與Twitter集成的應用程序..並想知道如何創建一個按鈕來添加設備的圖像在tweet.and也想知道要使用的框架,同時還應在代碼iOS嘰嘰喳喳應用程序添加圖像
我正在創建一個已與Twitter集成的應用程序..並想知道如何創建一個按鈕來添加設備的圖像在tweet.and也想知道要使用的框架,同時還應在代碼iOS嘰嘰喳喳應用程序添加圖像
你可以使用Twitter的框架,它包括在內,因爲iOS 5的
和代碼我使用:
- (IBAction)twitter:(id)sender {
if([TWTweetComposeViewController canSendTweet])
{
NSLog(@"Ready to Tweet.");
TWTweetComposeViewController *tweetComposer = [[TWTweetComposeViewController alloc] init];
[tweetComposer setInitialText:[NSString stringWithFormat:@"My message"]];
[tweetComposer addImage:[UIImage imageNamed:@"114x114"]];
[tweetComposer addURL:[NSURL URLWithString:@"http://myPage"]];
tweetComposer.completionHandler = ^(TWTweetComposeViewControllerResult result){
if(result == TWTweetComposeViewControllerResultDone){
NSLog(@"Tweeted.");
} else if(result == TWTweetComposeViewControllerResultCancelled) {
NSLog(@"Cancelled.");
}
[self.navigationController dismissViewControllerAnimated:YES completion:nil];
};
[self presentModalViewController:tweetComposer animated:YES];
}else {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Oops"
message:@"You can't send a tweet right now, make sure your device has an internet connection and you have at least one Twitter account setup"
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
[alert release];
}
}
這樣一個偉大的答案。 – Fattie