我有一个iOS应用程序,它有一系列的图像在滚动视图(相机图片)。我希望能够将这些作为一个组单独或集体发布到一个url上。
有没有人能给我举个例子或者一些示例代码来帮助我入门?
非常感谢
发布于 2012-08-05 18:00:41
在这种情况下,如果您设置了您的服务器(我现在不这样做,因为我使用了quickblox现成的解决方案),请尝试向服务器发送GET-request。您可以这样尝试:(source - How to send a Get request in iOS? )
NSString *getString = [NSString stringWithFormat:@"parameter=%@",yourvalue];
NSData *getData = [getString dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
NSString *getLength = [NSString stringWithFormat:@"%d", [getData length]];
NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease];
[request setURL:[NSURL URLWithString:@"https:yoururl"]];
[request setHTTPMethod:@"GET"];
[request setValue:postLength forHTTPHeaderField:@"Content-Length"];
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
[request setHTTPBody:getData];
self.urlConnection = [[[NSURLConnection alloc] initWithRequest:request delegate:self] autorelease];
NSAssert(self.urlConnection != nil, @"Failure to create URL connection.");
// show in the status bar that network activity is starting
[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
对于更高级的首选项,我建议您尝试学习http://allseeing-i.com/ASIHTTPRequest/
发布于 2012-08-05 06:01:23
为此,您可以创建文件服务器或使用其他maded。看看这个:http://quickblox.com/ --他们的服务器有blobs和ios api,所以下载|上传文件很简单,用代码实现。首先,你需要注册你的账号,然后注册你的应用程序( https://admin.quickblox.com/signin )(这并不难,几分钟),然后,根据网站的说明将Quickblox auth添加到你的应用程序中,然后使用QBBlobs下载照片。祝好运!
https://stackoverflow.com/questions/11811928
复制相似问题