首页 > 代码库 > IOS - 设置与帮助界面

IOS - 设置与帮助界面

设置与帮助
改动头像, 改动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; // 改动登录password
    Setting600Item *_chunyuTel; // 移动客服
    Setting600Item *_helpItem; // 帮助
    Setting600Item *_shengMing; // 声明
    Setting600Item *_aboutUs; // 关于我们

    Setting600SeparateItem *_separateItem;  // 空白切割cell

    FilledColorButton *_logoutButton; // 注销button

    UIView *_logoutFooterView;
}

- (id) initWithQuery:(NSDictionary *)query {
    self = [super initWithQuery: query];
    if (self) {
        self.title = @"设置与帮助";
        [[NSNotificationCenter defaultCenter] addObserver:self
                                                 selector:@selector(createModel)
                                                     name:kRegisterLocalPassword
                                                   object: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:_figureItem
                                 tapBlock:^BOOL(id object, id target, NSIndexPath *indexPath) {
                                     [_self editUserFigure];
                                     return YES;
                                 }];

    // 改动登录password
    _changeSecret = [[Setting600Item alloc] initWithTitle: @"改动登录password"];
    _changeSecret.type = kSetting600Top;
    [self.tableViewActions attachToObject: _changeSecret
                                 tapBlock:^BOOL(id object, id target, NSIndexPath *indexPath) {
                                     ModifyPasswordViewController *controller = [ModifyPasswordViewController new];
                                     [_self cyPresentViewController:controller
                                                           animated:YES];
                                     return NO;
                                 }];

    // 移动客服
    _chunyuTel = [[Setting600Item alloc] initWithTitle: @"移动客服"];
    _chunyuTel.type = kSetting600Middle;
    [self.tableViewActions attachToObject: _chunyuTel
                                 tapBlock: ^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: _helpItem
                                 tapBlock: ^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:_shengMing
                                 tapBlock:^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:_aboutUs
                                 tapBlock:^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:11
                                          fontColor: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: logoutRect
                                                       color: RGBCOLOR_HEX(0xe85454)
                                            highlightedColor: RGBCOLOR_HEX(0xa43939)
                                                   textColor: [UIColor whiteColor]
                                                       title: @"注销"
                                                    fontSize: 16*kViewRadio
                                                      isBold: YES];
    [_logoutButton addTarget: self
                      action: @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:dataItems
                                                             delegate:self.cellFactory];
}


#pragma mark - btn-selectors
// 点击注销
- (void) onLogOutBtnpressed:(UIButton*) sender {
    NIDPRINTMETHODNAME();

    // 登出
    [[AutoLoginManager sharedInstance] logout];


    // 更新当前的界面
    [self createModel];

    [self backToLastController: nil];

    // 让别的地方改变UI
    [[NSNotificationCenter defaultCenter] postNotificationName:kNotificationUserLogout
                                                        object:nil];

    // 获取未登录的badge
    [[NSNotificationCenter defaultCenter] postNotificationName:kNotificationCheckBadge
                                                        object:nil];
}



@end

效果
技术分享


技术分享

<script type="text/javascript"> $(function () { $(‘pre.prettyprint code‘).each(function () { var lines = $(this).text().split(‘\n‘).length; var $numbering = $(‘
    ‘).addClass(‘pre-numbering‘).hide(); $(this).addClass(‘has-numbering‘).parent().append($numbering); for (i = 1; i <= lines; i++) { $numbering.append($(‘
  • ‘).text(i)); }; $numbering.fadeIn(1700); }); }); </script>

IOS - 设置与帮助界面