下載UIImages我試圖下載一款用於一些圖片以這樣的方式來自收件箱
-(void)catchTheImage{
NSString *title = [[NSUserDefaults standardUserDefaults]objectForKey:@"Folder3"];
PhotoViewController* sharedSingleton = [PhotoViewController sharedManager];
NSString *filename2 = [NSString stringWithFormat:@"/%@photofile.png.%ld", title, (long)sharedSingleton.tagNumber];
NSString *tmpPngFile = [NSTemporaryDirectory() stringByAppendingPathComponent:[NSString stringWithFormat:@"%@", filename2]];
[restClient loadFile:filename2 intoPath:tmpPngFile];
[NSTimer scheduledTimerWithTimeInterval:10 target:self selector:@selector(lf) userInfo:nil repeats:NO];
}
-(void)lf{
NSString *tmpPngFile = [NSTemporaryDirectory() stringByAppendingPathComponent:[NSString stringWithFormat:@"%@", filename2]];
UIImage* image = [UIImage imageWithContentsOfFile:tmpPngFile];
photoView.image = image;
}
我知道計時器是不是一個好主意,但它只是嘗試。 TagNumber可以是1,2或3,因爲Dropbox上的圖像是3,但圖像不顯示。我認爲他們沒有保存在文件夾中。可能是我的NSTemporaryDirectory是如何工作的誤解......
擺脫計時器。您需要實現在文件實際下載時調用的Dropbox委託方法。您將在該位置從臨時目錄加載圖像。 – rmaddy