首页 新闻 会员 周边 捐助

采用ios6.0新特性分享新浪微博异常(SLRequest requestForServiceType SLServiceTypeSinaWeibo)

0
悬赏园豆:50 [待解决问题]

只分享文字可以,如果加入

[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];

            });

        }];

    }

}

< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册