ITeye博客

遍历指定目录下的文件,将复合条件的文件加载到列表(UITableView))

helmsman_xcode · 2011-08-22 09:10 · ios-综合基础文章 · 移动开发 · Markdown

本站最新网址:<http://www.helmsmansoft.com > 欢迎关注


- (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];
    

}

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。