(xcode和編程新手)我嘗試連接/下載/保存到變量並在UIImageView中從FTP服務器顯示圖像。代碼如下。任何幫助建議,將不勝感激。如何從ftp服務器下載並顯示圖像
- (void)viewDidLoad
{
//sets label to notify user whats happening
NSMutableString *labelString;
labelString = [NSMutableString stringWithString: @"Connecting"];
[labelDymamic setText: labelString];
//variable for ftp location
NSString *ftpLocation = [NSString stringWithFormat:@"ftp2.bom.gov.au/anon/sample/gms/IDE00003.201011170430.gif"];
//variable to recieve data
NSMutableData *responseData;
//loads ftpLocation into url
NSURL *url = [NSURL URLWithString:ftpLocation];
//sets label to notify user whats happening
NSMutableString *labelStringDownloading;
labelStringDownloading = [NSMutableString stringWithString: @"Downloading"];
[labelDymamic setText: labelStringDownloading];
//Connect to ftp
self.ftpImageView.image = [UIImage imageNamed:@"Icon.png"];
self.labelDymamic.text = @"Receiving";
NSURLRequest *request = [NSURLRequest requestWithURL:url];
(void) [[NSURLConnection alloc] initWithRequest: request delegate:self];
//download image
//save to variable
//display to screen
//sets label to notify application loading complete
NSMutableString *labelLoadedString;
labelLoadedString = [NSMutableString stringWithString: @"Radar"];
[labelDymamic setText: labelLoadedString];
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
目前所有顯示的都是帶有labelLoadedString變量「Radar」的白色屏幕。
感謝 艾倫
xcode是一個IDE只有 –
我相信@ Daij-Djan意思是你標記了這個錯誤。將來,請標記爲「iOS」,「objective-c」或其他類似建設性的內容。雖然這實際上並不能幫助回答這個問題,不是嗎? ;) –
我發現99%的ppl做錯了^^對不起,如果我太短:D(我的答案應該更有幫助) –