- (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;
}
untitled.plist 这个文件中有一级菜单 classes 和二级菜单 item 为什么运行之后只出现了二级菜单,没有一级菜单 高分急求解
//得到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;
}
untitled.plist 这个文件中有一级菜单 classes 和二级菜单 item 为什么运行之后只出现了二级菜单,没有一级菜单 高分急求解
解决方案 »
- Objective-C的三种编译环境
- 往php的服务器发送“username”并接收返回的数据
- 关于json 为什么服务端提示我访问了两次
- 移动手机链接服务器问题
- 这个问题怎么解决啊
- iOS openfire即时聊天 遇到的问题卡好久了
- 新手求助,刚接触ui想试试真机测试,出现问题。
- 怎么设置进入一个UITableViewController 的时候 直接滚动到 组尾的尾部
- 个推推送iOS版 常见问题详解
- 集成环信3.0的项目里使用Masonry,不能使用make.top.equalto(self.view.top),必须加上mas_
- centos6下jira问题
- CCOrbitCamera 参数详解
安代码来说它的结构应该是:每一个key对应一个array!
Key Type Value
root Dictionary
classes1 Array
item0 String 1.1
item0 String 1.2
item0 String 1.3
classes2 Array
item0 String 2.1
item0 String 2.2
item0 String 2.3
classes3 Array
item0 String 3.1
item0 String 3.2
item0 String 3.3