0
首先,我對objective-c和ios開發非常新穎。重新加載UITableView數據從下載plist
我有一個.plist從互聯網下載,然後用於填充UITableView。如下所示,我可以在AppDelegate的ApplicationDidLaunch方法中工作。
NSString *path = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSString *finalPath = [path stringByAppendingPathComponent:@"Data.plist"];
NSURL *theFileURL = [NSURL URLWithString:@"http://dl.dropbox.com/u/8068058/Data.plist"];
NSDictionary *replace = [[NSDictionary alloc] initWithContentsOfURL:theFileURL];
if (replace != nil){
[replace writeToFile:finalPath atomically:YES];
}
然後,我將其設置爲數據通路
NSString *Path = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSString *DataPath = [Path stringByAppendingPathComponent:@"Data.plist"];
NSDictionary *tempDict = [[NSDictionary alloc] initWithContentsOfFile:DataPath];
self.data = tempDict;
[tempDict release];
這是所有罰款,然後我填充的TableView並顯示它。如果我向顯示錶格的NavgationController添加一個'刷新'按鈕。當我按下它並運行相同的下載代碼後
[self.tableView reloadData];
我什麼也沒得到,有沒有人知道如何解決這個問題?
是你的表格視圖迷上了嗎? – aforaudrey
我對錶格視圖有以下代碼。 self.tableDataSource = tempArray; 然後我有代碼將tabeDataSource設置爲plist的objectAtKey。 該表在第一次運行時表現良好,但在應用運行時我無法刷新數據 – jrgrs
我的意思是,您的表視圖與Storyboard/IB中的控制器等掛鉤? – aforaudrey