首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >iPhone DrillDown

iPhone DrillDown
EN

Stack Overflow用户
提问于 2010-12-23 19:43:49
回答 2查看 186关注 0票数 0

万岁。我有一个tableView,它列出了我的文档目录中的内容。我有一些压缩文件在里面。如果我触摸tableView中的一个文件,相应的压缩文件将被解压缩并解压到一个临时目录(NSTemporaryDirectory())中。

问题是如何浏览我在tableView中提取的内容。假设解压的压缩文件包含文件夹,我应该能够在tableView中查看它们。实际上,流程应该像DrillDown一样。

我可以解压压缩文件,但问题是,必须在tableView中导航它们。请给我一些想法或一些源代码,以帮助我的问题。

这是我的didSelectRowAtIndexPath:部分,

代码语言:javascript
复制
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的document目录中推送相同的内容

请帮帮我..

谢谢。。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2010-12-23 19:57:52

你告诉你的RootViewController在哪里打开一条新的路径?对我来说,看起来您使用旧路径再次打开相同的RootViewController,因此它肯定会再次打开相同的路径

票数 1
EN

Stack Overflow用户

发布于 2010-12-24 02:57:31

您应该添加一个属性来设置控制器类的当前文件路径。您可以编写一个指定的初始化器,如下所示:

代码语言:javascript
复制
- (id)initWithDirectoryPath:(NSString*)path {
    self = [super initWithNibName:@"DirectoryViewController" bundle:nil];
    if (self != nil) {
        self.directoryPath = path;
        self.navigationItem.title = [path lastPathComponent];
    }
}

然后,您可以使用以下命令创建视图控制器并将其推送到导航控制器上:

代码语言:javascript
复制
DirectoryViewController *viewController = [[DirectoryViewController alloc] initWithDirectoryPath:path];
[self.navigationController pushViewController:viewController animated:YES];    
[viewController release];

别忘了释放VC!

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/4518435

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档