---
title: "遍历指定目录下的文件，将复合条件的文件加载到列表(UITableView))"
author: "helmsman_xcode"
date: "2011-08-22T09:10:27Z"
tags: []
categories: ["移动开发"]
slug: "uitableview"
draft: false
lastmod: "2011-09-15T09:03:30Z"
id: 1154726
url: "https://helmsman-xcode.iteye.com/blog/1154726"
---

<span style="color:red">本站最新网址：<http://www.helmsmansoft.com > 欢迎关注</span>


```Ios

- (void)viewDidLoad
{
    NSFileManager *fileManager = [[nsfilemanager defaultmanager] init];
    everyTitle = [[nsmutablearray alloc] init];
    NSArray *filePaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *filePath = [filepaths objectatindex:0];
//    NSLog(@"%@",filePath);
    NSDirectoryEnumerator *direnum = [filemanager enumeratoratpath:filepath];
    //    NSMutableArray *array = [[nsmutablearray alloc] init];
    NSString *fileName;
    while ((fileName = [direnum nextobject])) {
        if([[filename pathextension] isEqualToString:@"pdf"]){
            
            NSArray *strings = [filename componentsseparatedbystring:@"."];
            NSString *fileTitle = [strings objectatindex:[strings count]-2];
       
            [everytitle addobject:filetitle];
        
        }
    }
    
    uiController = [[uiviewcontroller alloc] init];
    [uicontroller settitle:@"目录"];
    
    navController = [[uinavigationcontroller alloc] initWithRootViewController:uiController];
    navController.view.frame = CGRectMake(0, 0, 320, 460);
    [self.view addsubview:navcontroller.view];
    
    self.uiController.navigationItem.leftBarButtonItem = [[uibarbuttonitem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemBookmarks target:self action:@selector(tableUpdata)];
//    
    self.uiController.navigationItem.rightBarButtonItem = [[uibarbuttonitem alloc] initWithTitle:@"刷新列表" style:UIBarButtonItemStyleBordered target:self action:@selector(tableUpdata)];
    
    tableView *tableViews = [[tableview alloc] initWithStyle:UITableViewStylePlain];
    tableViews.view.frame = CGRectMake(0, 45, 320, 460);
    [tableviews thevalue:everytitle];
    [self.view addsubview:tableviews.view];
//    [tableviews release];
    

}

```