大佬教程收集整理的这篇文章主要介绍了ios – 使用AFNetworking 2.0加载图像,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
这是我到目前为止所得到的:
// publish text and image -(void)publishTextAndImage:(NSString*)resultDisplay and:(NSString*)subject with:(NSString*)nonce { imageData = UIImageJPEGRepresentation(SELEctedImage,0.7); // create a data object from SELEcted image NSString *myUUID = [[NSUUID UUID] UUIDString]; // create a UUID NSString *formatString = [NSString StringWithFormat:@"<img src=\"/wp-content/uploads/%@\"/>",myUUID]; NSString *contentString = [formatString StringByAppendingString:resultDisplay]; NSString *moodString = [NSString StringWithFormat:@"%d",self.moodnumber]; NSDictionary *parameters = @{@"title":subject,@"content":contentString,@"status":@"publish",@"author":@"wordpress",@"user_password":@"xrayyankee",@"nonce":nonce,@"categories":moodString,@"attachment":@"image/jpeg"}; AFhttprequestOperationManager *manager = [AFhttprequestOperationManager manager]; [manager POST:@"http://thrills.it/?json=posts/create_post" parameters:parameters construcTingBodyWithBlock:^(id<AFMultipartFormData> formData) { if (SELEctedImagE) { [formData appendPartWithFileData:imageData name:@"photo" filename:myUUID mimeType:@"image/jpeg"]; } } success:^(AFhttprequestOperation *operation,id responSEObject) { NSLog(@"JSON: %@",responSEObject); } failure:^(AFhttprequestOperation *operation,NSError *error) { NSLog(@"Error: %@",error); }];
}
谢谢你们
AFhttpClient *client = [[AFhttpClient alloc] initWithBaseURL:[NSURL URLWithString:@"http://thrills.it/?json=posts"]]; NSURLrequest *request = [client multipartFormrequestWithMethod:@"POST" path:@"create_post" parameters:parameters construcTingBodyWithBlock:^(id<AFMultipartFormData> formData) { if (SELEctedImagE) { [formData appendPartWithFileData:imageData name:@"photo" filename:myUUID mimeType:@"image/jpeg"]; } } ]; AFJSONrequestOperation *operation = [AFJSONrequestOperation JSONrequestOperationWithrequest:request success:^(NSURLrequest *request,NShttpURLResponse *response,id JSON) { NSLog(@"JSON: %@",responSEObject); } failure:^(NSURLrequest *request,NSError *error,id JSON) { NSLog(@"Error: %@",error); }]; [operation setUploadProgressBlock:^(NSUInteger bytesWritten,long long @R_836_10586@lBytesWritten,long long @R_836_10586@lBytesExpectedToWritE) { float progressvalue = (float)((doublE)@R_836_10586@lBytesWritten/(doublE)@R_836_10586@lBytesExpectedToWritE); NSLog(@"%f",progressvalue); }]; [self.queue addoperation:operation];
.
@property (nonatomic,strong) NSOperationQueue *queue;
我的客户端是先前创建的,但它是这样创建的.
我希望这会有所帮助.
以上是大佬教程为你收集整理的ios – 使用AFNetworking 2.0加载图像全部内容,希望文章能够帮你解决ios – 使用AFNetworking 2.0加载图像所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。