我有一个UITableView
列出我的文档目录的内容。我有一些 zip 文件。如果我触摸 中的文件UITableView
,相应的 zip 文件将被解压缩并提取到临时目录 ( NSTemporaryDirectory()
) 中。
问题是如何导航我在 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 的文档目录中推送相同的内容。