只分享文字可以,如果加入
[NSMutableDictionarydictionaryWithObjectsAndKeys:
@"ssstext", @"status", uiimage, @"pic", nil]
就会异常。
2012-12-14 09:44:56.427 [594:907] -[UIImage length]: unrecognized selector sent to instance 0xa71ee0
2012-12-14 09:44:56.430 [594:907] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIImage length]: unrecognized selector sent to instance 0xa71ee0'
- (void)shareImageWithText:(NSString *)text image:(UIImage *)uiimage
{
//myUIImage = [uiimage retain];
myUIImage = [[[[UIImagealloc] init] initWithCGImage:[uiimage CGImage]] autorelease];
ACAccountType *accountType = [accountStoreaccountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierSinaWeibo];
NSArray *accountArray = [accountStore accountsWithAccountType:accountType];
if (accountArray.count > 0) {
NSURL *url = [NSURLURLWithString:@"https://open.weibo.cn/2/statuses/upload.json"];
NSMutableDictionary *params = [NSMutableDictionarydictionaryWithObjectsAndKeys:@"image SLRequest post test.", @"status", myUIImage, @"pic", nil];
m_pRequest = [SLRequestrequestForServiceType:SLServiceTypeSinaWeibo
requestMethod:SLRequestMethodPOST
URL:url
parameters:[NSMutableDictionarydictionaryWithObjectsAndKeys:
@"ssstext", @"status", uiimage, @"pic", nil]];
//add image
//[request addMultipartData:(NSData *)uiimage withName:@"pic" type:@"multipart/form-data" filename:nil];
[m_pRequestperformRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) {
dispatch_async(dispatch_get_main_queue(), ^{
NSString *response = [[NSStringalloc] initWithData:responseData encoding:NSUTF8StringEncoding];
NSLog(@"Post comment result:%@",response);
[response release];
});
}];
}
}