2012-08-04 109 views

回答

2

在這種情況下,如果你設置了你的服務器(我現在怎麼做,因爲我使用了quickblox - 現成的解決方案)嘗試發送GET請求到服務器。你可以試試這個是這樣的: (源 - 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/

1

爲此,您可以創建文件服務器或使用其他maded。看看這個:​​- 他們的服務器上有blob和ios api,所以下載|簡單的代碼上傳文件。 (https://admin.quickblox.com/signin)(這並不難,幾分鐘) 然後,使用站點指令將QuickBlox認證添加到您的應用程序,然後使用QBBlobs下載照片。祝你好運!

+0

我已經有一臺服務器。只需要讓UIScrollView提供圖像的路徑等。 – jini 2012-08-04 22:27:04