当前位置: 代码迷 >> Iphone >> 小弟我写了个tableview 为什么不显示一级目录
  详细解决方案

小弟我写了个tableview 为什么不显示一级目录

热度:119   发布时间:2016-04-25 06:50:32.0
我写了个tableview 为什么不显示一级目录
- (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;
}

------解决方案--------------------
你说的一级目录是指什么?你打印过classes吗,确定classes没有问题吗?
  相关解决方案