AppDelegate.m
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
self.window = [[UIWindow alloc]initWithFrame:[UIScreen
mainScreen].bounds];
self.window.rootViewController = [[UINavigationController alloc]
initWithRootViewController:
[[MyTableViewController alloc]initWithStyle:UITableViewStyleGrouped]];
[self.window makeKeyAndVisible];
return YES;
}
MyTableViewController.m
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 4;
}
- (NSInteger)tableView:(UITableView *)tableView
numberOfRowsInSection:(NSInteger)section {
if(section == 2) return 3;
return 1;
}
//静态表格没有复用
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell =[[UITableViewCell alloc]initWithStyle:
UITableViewCellStyleValue1 reuseIdentifier:nil];
switch (indexPath.section) {
case 0:
cell.textLabel.text = @"关于本机";
break;
case 1:
cell.textLabel.text = @"辅助功能";
break;
case 2:
if(indexPath.row == 0)
cell.textLabel.text = @"键盘";
else if(indexPath.row == 1)
cell.textLabel.text = @"语言与地区";
else if(indexPath.row == 2)
cell.textLabel.text = @"词典";
break;
case 3:
cell.textLabel.text = @"还原";
break;
}
//辅助 大于号
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
return cell;
}
结果展示
image.png
网友评论