我有一個UITableView
其中列出了我的文檔目錄的內容。我有一些zip文件。如果我觸摸UITableView
中的文件,則會將相應的zip文件解壓縮並解壓縮到臨時目錄(NSTemporaryDirectory()
)中。UINavigationController向下鑽取表視圖
問題是如何瀏覽我在tableView中提取的內容。如果假設,提取的zip文件包含文件夾,我應該能夠在tableView中查看它們。其實這個流程應該像是一個深入的研究。
我能夠提取zip文件,但問題是,必須導航到他們在UITableView
。
這是我didSelectRowAtIndexPath:
部分:
NSString *filePath = //filePath;
if ([[NSFileManager defaultManager]fileExistsAtPath:filePath]) {
NSLog(@"File exists at path: %@",filePath);
} else {
NSLog(@"File does not exists at path: %@", filePath);
}
NSString *tmpDir =NSTemporaryDirectory();
ZipArchive *zip = [[ZipArchive alloc] init];
BOOL result = NO;
if ([zip UnzipOpenFile:filePath]) {
//zip file is there
if ([zip UnzipFileTo:tmpDir overWrite:YES]) {
//unzipped successfully
NSLog(@"Archive unzip Success");
result= YES;
} else {
NSLog(@"Failure To Extract Archive, maybe password?");
}
} else {
NSLog(@"Failure To Open Archive");
}
if ([[NSFileManager defaultManager] fileExistsAtPath:tmpDir isDirectory:&isDir] && isDir) {
NSLog(@"Its Folder");
//Prepare to tableview.
RootViewController *rvController =[[RootViewController alloc]initWithNibName:@"RootViewController"bundle:[NSBundle mainBundle]];
[self.navigationController pushViewController:rvController animated:YES];
}
但是,這是行不通的。它推送tableView中文檔目錄中的相同內容。