//
// PersonViewController.m
// UIImageViewDemo
//
// Created by huguobin on 15/12/1.
// Copyright (c) 2015年 huguobin. All rights reserved.
//
#import "PersonViewController.h"
#import "PersonCell.h"
#import "SexCell.h"
#import "IconCell.h"
@interface PersonViewController ()
@end
@implementation PersonViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
states = [[NSMutableDictionary alloc]init];
[states setObject:@"Lansing" forKey:@"Michigan"];
[states setObject:@"Sacremento" forKey:@"California"];
[states setObject:@"Albany" forKey:@"New York"];
[states setObject:@"Phoenix" forKey:@"Arizona"];
[states setObject:@"Tulsa" forKey:@"Oklahoma"];
tableArray = [states allKeys];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
// Return the number of rows in the section.
return [tableArray count]+3;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = nil;
static NSString *customXibCellIdentifier = @"cell1";
cell = [tableView dequeueReusableCellWithIdentifier:customXibCellIdentifier];
// tableView.separatorColor = [UIColor whiteColor];
// tableView.separatorStyle = YES;
cell.selectionStyle = UITableViewCellSelectionStyleNone;
if (cell==nil)
{
if(indexPath.row==0){
cell=[[[NSBundle mainBundle] loadNibNamed:@"PersonCell" owner:self options:nil]objectAtIndex:0];
// tableView.separatorStyle = NO;
cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
}else if(indexPath.row==1){
cell=[[[NSBundle mainBundle] loadNibNamed:@"SexCell" owner:self options:nil]objectAtIndex:0];
// tableView.separatorStyle = YES;
}else if(indexPath.row==2){
cell=[[[NSBundle mainBundle] loadNibNamed:@"IconCell" owner:self options:nil]objectAtIndex:0];
}else{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:customXibCellIdentifier];
//Arrow
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
}
switch (indexPath.row) {
case 0:
[((PersonCell *)cell).name setText:@"胡国彬"];
break;
case 1:
[((SexCell *)cell).sex setText:@"男"];
break;
case 2:
break;
case 3:
cell.textLabel.text = [tableArray objectAtIndex:indexPath.row-1];
default:
break;
}
return cell;
}
//行高
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
if(indexPath.row==2){
return 100;
}else
return 40;
}
//点击每一行的颜色
//- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
// // [tableView deselectRowAtIndexPath:indexPath animated:NO];
// UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
// [cell setSelectionStyle:UITableViewCellSelectionStyleNone]; //(这种是没有点击后的阴影效果)
// UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
//
// cell.selected = NO; // (这种是点击的时候有效果,返回后效果消失)
//}
//-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{
//
// cell.textLabel.backgroundColor = [UIColor redColor];
//}
//http://www.cnblogs.com/zcw-ios/articles/2574372.html
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
@end