- (void)viewDidLoad {
//得到untitled。plise 这个文件的位置
NSString *path = [[NSBundle mainBundle] pathForResource:@"untitled" 
    ofType:@"plist"];
// 将这个文件载入
NSDictionary *dict =[[NSDictionary alloc] initWithContentsOfFile:path]; 
self.movieTitle = dict;
[dict release];
//将里面的内容进行排序
NSArray *array = [[movieTitle allKeys] sortedArrayUsingSelector:@selector(compare:)];
self.classes = array;
    [super viewDidLoad];
    self.clearsSelectionOnViewWillAppear = NO;
    self.contentSizeForViewInPopover = CGSizeMake(320.0, 600.0);
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)aTableView {
     // 分成classes个部分
     return [classes count];

}- (NSInteger)tableView:(UITableView *)aTableView numberOfRowsInSection:(NSInteger)section {
// tableview 的行数   返回多少行
NSString *test = [classes objectAtIndex:section];
NSArray *movieSection = [movieTitle objectForKey:test];
return [movieSection count];

}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    static NSString *CellIdentifier = @"CellIdentifier";
    
    // Dequeue or create a cell of the appropriate type.
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
        cell.accessoryType = UITableViewCellAccessoryNone;
    }
    NSString *test = [classes objectAtIndex:[indexPath section]];
NSArray *movieSection =[movieTitle objectForKey:test];
    // Configure the cell.
    cell.textLabel.text = [movieSection objectAtIndex:[indexPath row]];
    return cell;
}
-(NSString *)tableView: (UITableView *) tableView
 titleForHearderInSection:(NSInteger) section{
NSString *test = [classes objectAtIndex:section];
return test;
}

解决方案 »

  1.   

    你说的一级目录是指什么?你打印过classes吗,确定classes没有问题吗?
      

  2.   

    我指的classes  是我在untitled.plist下写的那个目录的一级目录,打印classes只什么  新手 这事第一个写的东西   多指教下 谢谢!!
      

  3.   

    NSLog("%@", classes);
    这么打印一下看看classes是不是有问题
    还有就是你的classes在@property中加入了retain属性了吗
      

  4.   


    @property中是这样的@property (nonatomic, retain) NSArray *classes;  应该没问题吧
      问下 NSLog("%@", classes);  应该放哪   什么情况是有问题的呢   
    (问的是不是有点2  嘿嘿O(∩_∩)O~)
      

  5.   

    - (void)viewDidLoad {
    //得到untitled。plise 这个文件的位置
    NSString *path = [[NSBundle mainBundle] pathForResource:@"untitled" 
    ofType:@"plist"];
    // 将这个文件载入
    NSDictionary *dict =[[NSDictionary alloc] initWithContentsOfFile:path]; 
    self.movieTitle = dict;
    [dict release];
    //将里面的内容进行排序
    NSArray *array = [[movieTitle allKeys] sortedArrayUsingSelector:@selector(compare:)];
    self.classes = array;
    这里放一次,
    - (NSInteger)numberOfSectionsInTableView:(UITableView *)aTableView {
      // 分成classes个部分
    这里放一次,
    然后点开gdb,看看控制台里面打印出classes的数据时不是你想要的
      

  6.   

    没打印出数据就说明你那个classes是空的,当然就显示不了你说的一级目录了
      

  7.   

    对啊,如果你确定untitled.plist里有数据的话那就是你在进行数据处理或者赋值的某个位置出问题了,好好检查下吧
      

  8.   

    是这样的  在class下面有个子目录item   这个全部显示了而且是有序的 0~2 ,0~2。 0~2这样的 就是没有上一级的class
    查了两天了  写的应该没错   现在就怕是少了什么  
      

  9.   

    没你代码,帮不了你了,你仔细查查吧,肯定是classes没值的问题,你现在只能现把这里搞定看看能不能显示了
      

  10.   

    关于这个问题我还没有解决您能加下qq帮我一下吗 谢谢您了  真的急用   我的qq是1037431533