设置与帮助
改动头像, 改动password, 移动客服, 帮助, 声明, 关于我们.
代码
//
// IndexSetting600ViewController.h
// SymptomChecker
//
// Created by wang on 2015-7-21.
//
//#import "CYTableViewController.h"@interface IndexSetting600ViewController : CYTableViewController@end
//
// IndexSetting600ViewController.m
// SymptomChecker
//
// Created by wang on 2015-7-21.
//
//#import "IndexSetting600ViewController.h"
#import "UserCenter600Item.h"#import "UserInfoEditingItem.h" // 改动头像
#import "PortraitPickerViewController.h" // 照片视图#import "ModifyPasswordViewController.h" // 改动password
#import "LocalPasswordViewController.h"#import "CYWebFromLocalViewController.h" // 帮助/声明
#import "CYAboutUsViewController.h" // 关于我们#define kViewRadio viewWidth()/320@interface IndexSetting600ViewController () <PortraitPickerViewControllerDelegate>@end@implementation IndexSetting600ViewController {UserFigureEditingItem *_figureItem; // 改动头像PortraitPickerViewController *_portraitPickerViewController; // 改动头像视图Setting600Item *_changeSecret; // 改动登录passwordSetting600Item *_chunyuTel; // 移动客服Setting600Item *_helpItem; // 帮助Setting600Item *_shengMing; // 声明Setting600Item *_aboutUs; // 关于我们Setting600SeparateItem *_separateItem; // 空白切割cellFilledColorButton *_logoutButton; // 注销buttonUIView *_logoutFooterView;
}- (id) initWithQuery:(NSDictionary *)query {self = [super initWithQuery: query];if (self) {self.title = @"设置与帮助";[[NSNotificationCenter defaultCenter] addObserver:selfselector:@selector(createModel)name:kRegisterLocalPasswordobject:nil];}return self;
}- (void) dealloc {[[NSNotificationCenter defaultCenter] removeObserver: self];
}- (void) viewDidLoad {[super viewDidLoad];[self.tableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];[self createTableItems]; // 确保item已经创建出来
}- (void) viewWillAppear:(BOOL)animated {[super viewWillAppear: animated];
}//
// 创建一次仅仅需
//
- (void) createTableItems {CY_DEFINE_SELF_BAR(self);User* user = [User currentUser];// 改动头像_figureItem = [[UserFigureEditingItem alloc] initWithTitle:@"头像" value:[user.matPhoto getMediaUrl]];[self.tableViewActions attachToObject:_figureItemtapBlock:^BOOL(id object, id target, NSIndexPath *indexPath) {[_self editUserFigure];return YES;}];// 改动登录password_changeSecret = [[Setting600Item alloc] initWithTitle: @"改动登录password"];_changeSecret.type = kSetting600Top;[self.tableViewActions attachToObject: _changeSecrettapBlock:^BOOL(id object, id target, NSIndexPath *indexPath) {ModifyPasswordViewController *controller = [ModifyPasswordViewController new];[_self cyPresentViewController:controlleranimated:YES];return NO;}];// 移动客服_chunyuTel = [[Setting600Item alloc] initWithTitle: @"移动客服"];_chunyuTel.type = kSetting600Middle;[self.tableViewActions attachToObject: _chunyuTeltapBlock: ^BOOL(id object, id target, NSIndexPath *indexPath) {NSString* feedBackPhoneNumber = @"4001100866";[[UIApplication sharedApplication] openURL:[NSURL URLWithString: [NSString stringWithFormat: @"tel://%@", feedBackPhoneNumber]]];return YES;}];// 帮助_helpItem = [[Setting600Item alloc] initWithTitle: @"帮助"];_helpItem.type = kSetting600Middle;[self.tableViewActions attachToObject: _helpItemtapBlock: ^BOOL(id object, id target, NSIndexPath *indexPath) {CYWebFromLocalViewController* controller = [[CYWebFromLocalViewController alloc] initWithQuery:@{@"title" : @"帮助", @"local_name" : @"help"}];[self.navigationController pushViewController:controller animated:YES];return YES;}];// 声明_shengMing = [[Setting600Item alloc] initWithTitle: @"声明"];_shengMing.type = kSetting600Middle;[self.tableViewActions attachToObject:_shengMingtapBlock:^BOOL(id object, id target, NSIndexPath *indexPath) {CYWebFromLocalViewController* controller = [[CYWebFromLocalViewController alloc] initWithQuery:@{@"title" : @"声明", @"local_name" : @"statement"}];[self.navigationController pushViewController:controller animated:YES];return YES;}];// 关于我们_aboutUs = [[Setting600Item alloc] initWithTitle: @"关于我们"];_aboutUs.type = kSetting600Bottom;[self.tableViewActions attachToObject:_aboutUstapBlock:^BOOL(id object, id target, NSIndexPath *indexPath) {CYAboutUsViewController* controller = [[CYAboutUsViewController alloc] initWithQuery:@{@"title" : @"关于我们", @"local_name" : @"about"}];[self.navigationController pushViewController:controller animated:YES];return YES;}];// 切割_separateItem = [[Setting600SeparateItem alloc] init];// 底部视图_logoutFooterView = [UIView viewWithFrame:CGRectMake(0, 0, self.view.width, 92*kViewRadio)andBkColor:[UIColor clearColor]];self.tableView.tableFooterView = _logoutFooterView;// 版本号信息UILabel *versionLabel = [UILabel labelWithFrame:CGRectMake(0, 8*kViewRadio, viewWidth(), 12*kViewRadio)fontSize:11fontColor:RGBCOLOR_HEX(0x522121)text:[NSString stringWithFormat: @"当前版本号 :%@", @"1.0.0"]];[versionLabel setTextAlignment:NSTextAlignmentCenter];[_logoutFooterView addSubview:versionLabel];CGRect logoutRect = CGRectMake(16*kViewRadio,versionLabel.bottom+16*kViewRadio,viewWidth()-32*kViewRadio,44*kViewRadio);// 注销button_logoutButton = [[FilledColorButton alloc] initWithFrame: logoutRectcolor: RGBCOLOR_HEX(0xe85454)highlightedColor: RGBCOLOR_HEX(0xa43939)textColor: [UIColor whiteColor]title: @"注销"fontSize: 16*kViewRadioisBold: YES];[_logoutButton addTarget: selfaction: @selector(onLogOutBtnpressed:)forControlEvents: UIControlEventTouchUpInside];[_logoutFooterView addSubview:_logoutButton];}- (void)editUserFigure {_portraitPickerViewController = [[PortraitPickerViewController alloc] initWithParent:self];_portraitPickerViewController.delegate = self;[_portraitPickerViewController showOptions];
}- (void) createModel {NSArray *dataItems;if ([User hasLoggedIn]) {dataItems = @[_separateItem,_figureItem, // 改动头像_separateItem,_changeSecret,// 改动登录password_chunyuTel, // 移动客服_helpItem, // 帮助_shengMing, // 声明_aboutUs, // 关于我们_separateItem];} else {_logoutButton.hidden = YES;_logoutFooterView.height = 40;dataItems = @[_separateItem,_chunyuTel, // 移动客服_helpItem, // 帮助_shengMing, // 声明_aboutUs, // 关于我们_separateItem];}self.tableViewModel = [[NITableViewModel alloc] initWithListArray:dataItemsdelegate:self.cellFactory];
}#pragma mark - btn-selectors
// 点击注销
- (void) onLogOutBtnpressed:(UIButton*) sender {NIDPRINTMETHODNAME();// 登出[[AutoLoginManager sharedInstance] logout];// 更新当前的界面[self createModel];[self backToLastController: nil];// 让别的地方改变UI[[NSNotificationCenter defaultCenter] postNotificationName:kNotificationUserLogoutobject:nil];// 获取未登录的badge[[NSNotificationCenter defaultCenter] postNotificationName:kNotificationCheckBadgeobject:nil];
}@end
效果