#import "ViewController.h"
@interface ViewController ()<UITableViewDataSource>
@property (weak, nonatomic) IBOutlet UITableView *tableView;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.tableView.dataSource = self;
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 3;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
if(section == 0){
return 3;
}else if(section == 1){
return 2;
}else{
return 1;
}
return 2;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(nonnull NSIndexPath *)indexPath
{
UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil];
if(indexPath.section == 0){
if(indexPath.row == 0){
cell.textLabel.text = @"中国";
}else if(indexPath.row == 1){
cell.textLabel.text = @"日本";
}else{
cell.textLabel.text = @"韩国";
}
}else if(indexPath.section == 1){
if(indexPath.row == 0){
cell.textLabel.text = @"b南非";
}else{
cell.textLabel.text = @"索马里";
}
}else {
cell.textLabel.text = @"荷兰";
}
return cell;
}
-(NSString *)tableView:(UITableView*)tableView tetleForHeaderInsection:(NSInteger)section{
if(section == 0){
return @"亚洲";
}else if(section == 1){
return @"非洲";
}else{
return @"欧洲";
}
}
-(NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section{
if(section == 0){
return @"亚洲,yazhou";
}else if(section == 1){
return @"非洲,feizhou";
}else{
return @"欧洲,ouzhou";
}
}
}
@end