导航控制器中的IOS表视图
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了导航控制器中的IOS表视图相关的知识,希望对你有一定的参考价值。
Pulls data from a plist set up as a dictionary of arrays of strings.Creates multi-level TableView that can be nested inside a navigation controller.
Snippet shows key methods for 2 nested levels.
2 levels --> 2 classes (both of which extend UITableViewController)
// ---------- Top Level ---------------- - (void)viewDidLoad { self.title = @"Categories"; ofType:@"plist"]; initWithContentsOfFile:path]; self.buildings = dict; [dict release]; for(id name in buildings) { CategorySecondLevelViewController *controller = [[CategorySecondLevelViewController alloc] initWithStyle:UITableViewStylePlain]; controller.title = name; [array addObject:controller]; [controller release]; } self.categories = array; [array release]; [super viewDidLoad]; } - (UITableViewCell *)tableView:(UITableView *)tableView // reuse cell if possible UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier: CategoryCell]; if(cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle: UITableViewCellStyleDefault reuseIdentifier: CategoryCell] autorelease]; } // configure cell NSUInteger row = [indexPath row]; // extension point to include images if wanted UITableViewController *controller = [categories objectAtIndex:row]; cell.textLabel.text = controller.title; cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; return cell; } // ---------- Second Level ---------------- - (void)viewDidLoad { ofType:@"plist"]; initWithContentsOfFile:path]; self.list = values; [dict release]; [super viewDidLoad]; } - (UITableViewCell *)tableView:(UITableView *)tableView UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier: BuildingIdentifier]; if(cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:BuildingIdentifier] autorelease]; } NSUInteger row = [indexPath row]; cell.textLabel.text = [list objectAtIndex:row]; return cell; }
以上是关于导航控制器中的IOS表视图的主要内容,如果未能解决你的问题,请参考以下文章