77//
88
99#define kCellIdentifier_TitleValue @" TitleValueCell"
10+ #define kCellIdentifier_TitleDisclosure @" TitleDisclosureCell"
1011
1112#import " SettingAccountViewController.h"
1213#import " TitleValueCell.h"
14+ #import " TitleDisclosureCell.h"
15+
16+ #import " SettingPasswordViewController.h"
17+
1318@interface SettingAccountViewController ()
1419@property (strong , nonatomic ) UITableView *myTableView;
1520
@@ -43,31 +48,44 @@ - (void)loadView{
4348 tableView.delegate = self;
4449 tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
4550 [tableView registerClass: [TitleValueCell class ] forCellReuseIdentifier: kCellIdentifier_TitleValue ];
51+ [tableView registerClass: [TitleDisclosureCell class ] forCellReuseIdentifier: kCellIdentifier_TitleDisclosure ];
4652 [self .view addSubview: tableView];
4753 tableView;
4854 });
4955}
5056
5157#pragma mark TableM
5258
59+ - (NSInteger )numberOfSectionsInTableView : (UITableView *)tableView {
60+ return 2 ;
61+ }
62+
5363- (NSInteger )tableView : (UITableView *)tableView numberOfRowsInSection : (NSInteger )section {
54- NSInteger row = 2 ;
64+ NSInteger row = section == 0 ? 2 : 1 ;
5565 return row;
5666}
5767
5868- (UITableViewCell *)tableView : (UITableView *)tableView cellForRowAtIndexPath : (NSIndexPath *)indexPath {
59- TitleValueCell *cell = [tableView dequeueReusableCellWithIdentifier: kCellIdentifier_TitleValue forIndexPath: indexPath];
60-
61- switch (indexPath.row ) {
62- case 0 :
63- [cell setTitleStr: @" 邮箱" valueStr: self .myUser.email];
64- break ;
65- default :
66- [cell setTitleStr: @" 个性后缀" valueStr: self .myUser.global_key];
67- break ;
69+ if (indexPath.section == 0 ) {
70+ TitleValueCell *cell = [tableView dequeueReusableCellWithIdentifier: kCellIdentifier_TitleValue forIndexPath: indexPath];
71+
72+ switch (indexPath.row ) {
73+ case 0 :
74+ [cell setTitleStr: @" 邮箱" valueStr: self .myUser.email];
75+ break ;
76+ default :
77+ [cell setTitleStr: @" 个性后缀" valueStr: self .myUser.global_key];
78+ break ;
79+ }
80+ [tableView addLineforPlainCell: cell forRowAtIndexPath: indexPath withLeftSpace: kPaddingLeftWidth ];
81+ return cell;
82+ }else {
83+ TitleDisclosureCell *cell = [tableView dequeueReusableCellWithIdentifier: kCellIdentifier_TitleDisclosure forIndexPath: indexPath];
84+ [cell setTitleStr: @" 修改密码" ];
85+ [tableView addLineforPlainCell: cell forRowAtIndexPath: indexPath withLeftSpace: kPaddingLeftWidth ];
86+ return cell;
6887 }
69- [tableView addLineforPlainCell: cell forRowAtIndexPath: indexPath withLeftSpace: 20 ];
70- return cell;
88+
7189}
7290- (UIView *)tableView : (UITableView *)tableView viewForHeaderInSection : (NSInteger )section {
7391 UIView *headerView = [[UIView alloc ] initWithFrame: CGRectMake (0 , 0 , kScreen_Width , 20 )];
@@ -79,6 +97,11 @@ - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSIntege
7997}
8098- (void )tableView : (UITableView *)tableView didSelectRowAtIndexPath : (NSIndexPath *)indexPath {
8199 [tableView deselectRowAtIndexPath: indexPath animated: YES ];
100+ if (indexPath.section != 0 ) {
101+ SettingPasswordViewController *vc = [[SettingPasswordViewController alloc ] init ];
102+ vc.myUser = self.myUser ;
103+ [self .navigationController pushViewController: vc animated: YES ];
104+ }
82105}
83106
84107- (void )dealloc
0 commit comments