我有一个 UITableView 列出了我的文档目录的内容。我有一些zip文件。如果我在 UITableView, ,相应的zip文件被解压缩并在临时目录中提取(NSTemporaryDirectory()).

问题是如何导航我在表观视图中提取的内容。如果假设,提取的zip文件包含文件夹,则我应该能够在表观视频中查看它们。实际上,流应该像钻孔一样。

我能够提取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中的文档目录中推动相同的内容。

有帮助吗?

解决方案

您需要使用一个可以处理钻头的UinavigationController。每个钻探都是一个新的uitableviewController。

您需要第二个uitaiteViewController子类,该子类将处理显示ZIP中包含的文件。它可以具有NSString属性,该属性是通往邮政编码的完整路径。它使用该目录中的文件列表作为数据源。

在启动时,将原始的TableView(控制器)添加到UinavigationController的rootview中。当您点击列出zip文件的表视图时,您可以使用对提取的文件(新文件夹?)的引用将第二个UITATEVIEWCONTROLLER推向UinavigationController。

[UINavigationwController pushViewController:nextTableView animated:YES];

看到这个 苹果的旧代码示例 关于在 UINavigationController. 。另外,查看 uinavigationcontroller上的文档 来自苹果。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top