如何打开文件浏览器,并在ios中select.pdf文件

如何打开一个文件浏览器,当我的应用程序在iphone中点击一个button。它必须显示的文件扩展名为.pdf格式,并且必须保存到本地数据库。例如,如果我们想发送如果我们想要发送文件,我们附上一些文件。如果我们点击附加文件button,它将显示文件资源pipe理器。同样的方式,文件资源pipe理器必须打开,如果用户在iPhone中单击button请帮我解决这个问题。

我做了类似的IOS应用程序。 由于IOS没有(我认为)一个文件浏览器,你是在很大的温度,只允许使用你的应用程序的文件夹,当他点击附加文件,我打开一个UIPopoverController,我向他展示所有的扩展名为I想。 在我的情况是.csv文件,我使用这个algorithm:

_data= [[NSMutableArray alloc] init]; NSString *documentsPath= [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]; NSError *error; NSArray* files= [[NSFileManager defaultManager] contentsOfDirectoryAtPath:documentsPath error:&error]; NSRange range; for (NSString* file in files) { range = [file rangeOfString:@".csv" options:NSCaseInsensitiveSearch]; if (range.location!= NSNotFound) { [_data addObject:file]; } } 

_data是我在我的tableView中使用的一个数组来知道我所有的csv文件。 如果你想这样做的文件浏览器显示目录,并让用户看到文件recursion的目录。 我的表dataSource:

 - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return [_data count]; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell==nil) { cell= [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier]; } cell.textLabel.text=[_data objectAtIndex:indexPath.row]; return cell; } 

我希望它可以帮助你