#import "CYMemberCenterController.h"
#import <UIButton+WebCache.h>
#import "EPUserProfileViewController.h"
@interface CYMemberCenterController ()
@property(nonatomic,strong)NSMutableArray *menuArray;
@end
@implementation CYMemberCenterController
- (void)viewDidLoad {
[superviewDidLoad];
self.headView.titleLabel.text = @"个人中心";
self.headView.leftBtn.hidden = YES;
self.tableView.backgroundColor =rgb(242,242, 242);
self.menuArray = [[NSMutableArrayalloc]initWithCapacity:0];
NSArray *m1Array =@[@{@"name":@"我的会员信息",@"icon":@"ks_acc_lines",@"ctr":@"EPUserProfileViewController"},
@{@"name":@"我的邀请",@"icon":@"ks_acc_lines",@"ctr":@""}];
NSArray *m2Array =@[@{@"name":@"我的账户",@"icon":@"ks_acc_lines",@"ctr":@"CYMyAccountViewController"}];
NSArray *m3Array =@[@{@"name":@"消息",@"icon":@"ks_acc_lines",@"ctr":@"CYMessageListViewController"},
@{@"name":@"设置",@"icon":@"ks_acc_lines",@"ctr":@"MCSettingViewController"}];
[self.menuArrayaddObject:m1Array];//创建三个数组,里面装字典然后,在字典里面将数据封装起来。
[self.menuArrayaddObject:m2Array];
[self.menuArrayaddObject:m3Array];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
return self.menuArray.count;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
if (section !=0) {
return10;
}
return0.0;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
return45;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
NSArray *secArray = self.menuArray[section];
return secArray.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
staticNSString *Identifier =@"Cell";
UITableViewCell *cell = [tableViewdequeueReusableCellWithIdentifier:Identifier];
if (!cell) {
cell = [[UITableViewCellalloc]initWithStyle:UITableViewCellStyleDefaultreuseIdentifier:Identifier];
cell.backgroundColor = [UIColorwhiteColor];
cell.accessoryType =UITableViewCellAccessoryDisclosureIndicator;
}
NSArray *funcArray = self.menuArray[indexPath.section];
NSDictionary *menuDit = funcArray[indexPath.row];
cell.textLabel.text = menuDit[@"name"];
cell.textLabel.font = [UIFontsystemFontOfSize:14];
[cell.imageViewsetImage:[UIImageimageNamed:menuDit[@"icon"]]];
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
[tableView deselectRowAtIndexPath:indexPathanimated:YES];
NSArray *funcArray = self.menuArray[indexPath.section];
NSDictionary *menuDit = funcArray[indexPath.row];
UIViewController *ctr = (UIViewController*)[[NSClassFromString(menuDit[@"ctr"])alloc]init];
if ([ctrisKindOfClass:[EPUserProfileViewControllerclass]])//如果需要,可以将某个控制器单独提出来,进行传值
{
EPUserProfileViewController *memberCtr = (EPUserProfileViewController*)ctr;
memberCtr.profileEntryType =pUserInfoType;
}
ctr.hidesBottomBarWhenPushed =YES;
[self.navigationControllerpushViewController:ctranimated:YES];
}
- (void)didReceiveMemoryWarning {
[superdidReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end