2.随便导入一张图片,比如haoyou.png
3.ViewController.h
#import <uikit uikit.h="">
#import "ASIHTTPRequest.h"
#import "ASIFormDataRequest.h"
@interface ViewController : UIViewController
@property (nonatomic, copy)NSString *m_auth
@end</asihttprequestdelegate></uikit>
4.ViewController.m 添加蔽锋两个按钮
(void)viewDidLoad {
[super viewDidLoad]
UIButton *loginBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect]
loginBtn.frame = CGRectMake(100, 20, 120, 40)
[loginBtn setTitle:@"登录" forState:UIControlStateNormal]
[loginBtn addTarget:self action:@selector(login) forControlEvents:UIControlEventTouchUpInside]
[self.view addSubview:loginBtn]
UIButton *uploadBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect]
uploadBtn.frame = CGRectMake(100, 80, 120, 40)
[uploadBtn setTitle:@"上传" forState:UIControlStateNormal]
[uploadBtn addTarget:self action:@selector(upload) forControlEvents:UIControlEventTouchUpInside]
[self.view addSubview:uploadBtn]
}
宏启 5.实现login和upload两个方法
- (void)login {
NSURL *url = [NSURL URLWithString:@"..."]//此处省略请求url
//请求
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url]
request.tag = 10
request.delegate = self
[request startAsynchronous]
}
- (void)upload {
NSURL* url = [NSURL URLWithString:@"..."]//此处省略请求url
UIImage* img = [UIImage imageNamed:@"haoyou.png"]
NSData* data = UIImagePNGRepresentation(img)
//ASIFormDataRequest请求是post请求,可以查看其源码
ASIFormDataRequest* request = [ASIFormDataRequest requestWithURL:url]
request.tag = 20
request.delegate = self
[request setPostValue:self.m_auth forKey:@"m_auth"]
//[request setFile:@"tabbar.png" forKey:@"haoyou"]//如果有路径,上传文件
[request setData:data withFileName:@"tmp.png" andContentType:@"image/png" forKey:@"headimage"]
// 数据文件名,随便起 文件类型设置key
[request startAsynchronous]
}
6.实现协议
- (void)requestFailed:(ASIHTTPRequest *)request {
NSLog(@"请求失败")
}
- (void)requestFinished:(ASIHTTPRequest *)request {
if (request.tag == 10) {
NSDictionary * dic = [NSJSONSerialization JSONObjectWithData:request.responseData options:0 error:nil]
self.m_auth = [dic objectForKey:@"m_auth"]
NSLog(@"%@", self.m_auth)
}
if (request.tag == 20) {
NSLog(@"%@", request.responseString)
}
}
你所阐述的问题就是指的是
向服务器传一个文雹核丛件。
多用post
请求。用
自带的NSURLConnection
或者ASI
等源樱
都可以。你过程说的明了,不知道是具体哪个环节有问题。
写文件?传文件?ios文件写氏枝 *** 作和文件上传到服务器
asi文件因该是直接放入gta4主文件夹的。好像需要配合ini文件。另外,你还需要打上asi补丁。如宴烂磨果这不行,网上还有许多mod,比如保镖、晌斗第一人称、跳舞、随身听等等。如果你要就发邮件给我,我也是1.0.4.0的,历敏个人亲测能用。
1378746669@qq.com
有些dsound文件不需要替换,以免游戏进不去
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)