嗨,大家好 我在Twitter上分享没有Twitter表格,我使用此代码登录twitter我的客户按钮
[[Twitter sharedInstance] logInWithCompletion:^
(TWTRSession *session, NSError *error) {
if (session) {
NSLog(@"signed in as %@", [session userName]);
self.twitter_name_lbl.hidden =NO;
self.twitter_name_lbl.text =[NSString stringWithFormat:@"%@",[session userName]];
self.Twitterloginstr=@"1";
} else {
NSLog(@"error: %@", [error localizedDescription]);
}
}];
登录后我使用以下代码共享
- (IBAction)postbutton_touch:(id)sender
{
NSData *data = UIImagePNGRepresentation(self.share_imeg.image);
ACAccountStore *account = [[ACAccountStore alloc] init];
ACAccountType *accountType = [account accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];
NSArray *arrayOfAccons = [account accountsWithAccountType:accountType];
[account requestAccessToAccountsWithType:accountType options:nil completion:^(BOOL granted, NSError *error) {
if (granted == YES) {
// Populate array with all available Twitter accounts
NSArray *arrayOfAccounts = [account accountsWithAccountType:accountType];
if ([arrayOfAccounts count] > 0) {
ACAccount *acct = [arrayOfAccounts objectAtIndex:0];
NSDictionary *message = @{@"status": @"From my app"};
NSURL *requestURL = [NSURL URLWithString:@"https://upload.twitter.com/1/statuses/update_with_media.json"];
SLRequest *postRequest = [SLRequest
requestForServiceType:SLServiceTypeTwitter
requestMethod:SLRequestMethodPOST
URL:requestURL parameters:message];
[postRequest addMultipartData:data withName:@"media" type:@"image/png" filename:@"TestImage"];
postRequest.account = acct;
[postRequest performRequestWithHandler:
^(NSData *responseData, NSHTTPURLResponse
*urlResponse, NSError *error)
{
if (error) {
NSLog(@"%@",error.description);
}
else {
NSLog(@"Upload Sucess !");
}
}];
}
}
}];
}
这里我得到了accountType的问题是nill我不知道哪个点我错过了...任何人帮我解决了问题从守护程序返回的错误:错误Domain = com.apple.accounts Code = 9& #34;(空)"" 在此先感谢