ho trovato e utilizzato così tanti grandi risposte su questo sito, Grazie a tutti, pensano che il momento di restituire :) Elaborando risposta di Noè, questo è il codice finale che ha lavorato per me per ottenere un'immagine e il testo su un tweet usando TWRequest ...
TWRequest *postRequest = [[TWRequest alloc] initWithURL:[NSURL URLWithString:@"https://upload.twitter.com/1/statuses/update_with_media.json"] parameters:nil requestMethod:TWRequestMethodPOST];
UIImage * image = [UIImage imageNamed:@"myImage.png"];
//add text
[postRequest addMultiPartData:[@"I just found the secret level!" dataUsingEncoding:NSUTF8StringEncoding] withName:@"status" type:@"multipart/form-data"];
//add image
[postRequest addMultiPartData:UIImagePNGRepresentation(image) withName:@"media" type:@"multipart/form-data"];
// Set the account used to post the tweet.
[postRequest setAccount:twitterAccount];
// Perform the request created above and create a handler block to handle the response.
[postRequest performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) {
NSString *output = [NSString stringWithFormat:@"HTTP response status: %i", [urlResponse statusCode]];
[self performSelectorOnMainThread:@selector(displayText:) withObject:output waitUntilDone:NO];
}];
ho trovato utilizzando TWRequest di essere la soluzione migliore per il mio scenario come io non volevo che l'utente sia in grado di modificare il post prima di tweeting (che era il problema con TWTweetComposeViewController)
Questo codice è applicabile solo in ios5? o posso usarlo solo per le versioni inferiori – iPhone
iOS5, ci sono librerie di twitter opensource che possono aiutarti se hai bisogno di una
staticfiction
Puoi fare la stessa cosa in iOS 4 con [DETweetComposeViewController] (https://github.com/ doubleencore/DETweetComposeViewController). –