gpt4 book ai didi

IOS推特应用添加图片

转载 作者:行者123 更新时间:2023-11-29 11:08:03 26 4
gpt4 key购买 nike

我正在创建一个与 Twitter 集成的应用程序。我想知道如何创建一个按钮来在推文中添加设备图像。我还想知道使用哪个框架以及还有代码在哪里

最佳答案

你可以只使用 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];
}
}

关于IOS推特应用添加图片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12830967/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com