- (UITableView *)tableView
{
if(!_tableView)
{
_tableView = [[UITableView alloc] initWithFrame:nckR(0, 0, MW, MH - 92)];
_tableView.backgroundColor = [UIColor greenColor];
_tableView.dataSource = self;
_tableView.delegate = self;
_tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
}
return _tableView;
}
#pragma mark-
#pragma mark tableView的代理方法
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)sectionIndex
{
return 30;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 3;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 5;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)sectionIndex
{
if (sectionIndex == 0)
{
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.frame.size.width, 34)];
view.backgroundColor = [UIColor colorWithRed:167/255.0f green:167/255.0f blue:167/255.0f alpha:0.6f];
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(10, 8, 0, 0)];
label.text = @"女士";
label.font = [UIFont systemFontOfSize:15];
label.textColor = [UIColor whiteColor];
label.backgroundColor = [UIColor clearColor];
[label sizeToFit];
[view addSubview:label];
return view;
}
else if (sectionIndex == 1)
{
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.frame.size.width, 34)];
view.backgroundColor = [UIColor colorWithRed:167/255.0f green:167/255.0f blue:167/255.0f alpha:0.6f];
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(10, 8, 0, 0)];
label.text = @"男士";
label.font = [UIFont systemFontOfSize:15];
label.textColor = [UIColor whiteColor];
label.backgroundColor = [UIColor clearColor];
[label sizeToFit];
[view addSubview:label];
return view;
}
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.frame.size.width, 34)];
view.backgroundColor = [UIColor colorWithRed:167/255.0f green:167/255.0f blue:167/255.0f alpha:0.6f];
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(10, 8, 0, 0)];
label.text = @"生活";
label.font = [UIFont systemFontOfSize:15];
label.textColor = [UIColor whiteColor];
label.backgroundColor = [UIColor clearColor];
[label sizeToFit];
[view addSubview:label];
return view;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"SearchCell"];
if (!cell) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"SearchCell"];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
if (indexPath.section ==0) {
NSArray * woman = @[@"COAT 上衣",
@"THE TROUSERS 裙",
@"THE SKIRT 裤",
@"UNSER WEAR 内衣",
@"SOCKS 袜",
@"HAT 帽",@"SHOES 鞋"];
cell.textLabel.text = woman[indexPath.row];
}
else if (indexPath.section == 1) {
NSArray * man = @[@"COAT 上衣",@"THE TROUSERS 裙",@"THESKIRT裤",@"UNSER WEAR 内衣", @"SOCKS 袜", @"HAT 帽",@"SHOES 鞋"];
cell.textLabel.text =man[indexPath.row];
}
else if (indexPath.section ==2){
NSArray * live = @[@"COAT 上衣",
@"THE TROUSERS 裙",
@"THE SKIRT 裤",
@"UNSER WEAR 内衣",
@"SOCKS 袜",
@"HAT 帽",@"SHOES 鞋"];
cell.textLabel.text = live[indexPath.row];
}
}
return cell;
}