万岁。我有一个tableView,它列出了我的文档目录中的内容。我有一些压缩文件在里面。如果我触摸tableView中的一个文件,相应的压缩文件将被解压缩并解压到一个临时目录(NSTemporaryDirectory())中。
问题是如何浏览我在tableView中提取的内容。假设解压的压缩文件包含文件夹,我应该能够在tableView中查看它们。实际上,流程应该像DrillDown一样。
我可以解压压缩文件,但问题是,必须在tableView中导航它们。请给我一些想法或一些源代码,以帮助我的问题。
这是我的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的document目录中推送相同的内容
请帮帮我..
谢谢。。
发布于 2010-12-23 19:57:52
你告诉你的RootViewController在哪里打开一条新的路径?对我来说,看起来您使用旧路径再次打开相同的RootViewController,因此它肯定会再次打开相同的路径
发布于 2010-12-24 02:57:31
您应该添加一个属性来设置控制器类的当前文件路径。您可以编写一个指定的初始化器,如下所示:
- (id)initWithDirectoryPath:(NSString*)path {
self = [super initWithNibName:@"DirectoryViewController" bundle:nil];
if (self != nil) {
self.directoryPath = path;
self.navigationItem.title = [path lastPathComponent];
}
}然后,您可以使用以下命令创建视图控制器并将其推送到导航控制器上:
DirectoryViewController *viewController = [[DirectoryViewController alloc] initWithDirectoryPath:path];
[self.navigationController pushViewController:viewController animated:YES];
[viewController release];别忘了释放VC!
https://stackoverflow.com/questions/4518435
复制相似问题