TableView cell section TextField ALert

主要功能table设计两个section,每个section遍历获取cell数据,都是使用系统原生cell,没有初始化。

点击cell,进行页面切换,即congtroller切换。

增加弹框,并加入输入框。


//
//  SecuritySetingViewController.m
//  NetsUi
//
//  Created by lishuai on 2017/8/1.
//  Copyright © 2017年 lishuai. All rights reserved.
//

#import "SecuritySetingViewController.h"

@interface SecuritySetingViewController()<UITableViewDelegate,UITableViewDataSource,UIAlertViewDelegate>{
    UITextField *textPass;
}
@property (nonatomic, strong) NSArray *array;
@property (nonatomic, strong) NSArray *arraytwo;
@property (nonatomic, strong) UITableView *tableView;

@end

@implementation SecuritySetingViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self configureUI];
}
- (void)configureUI
{
    _array = @[@"Sign In Password",@"Guesture Password",@"TouchID"];
    _arraytwo = @[@"Security Question"];
    [self.view addSubview:self.tableView];
}

- (UITableView *)tableView
{
    if (!_tableView) {
        _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 30, self.view.frame.size.width, self.view.frame.size.height) style:UITableViewStyleGrouped];
        _tableView.dataSource = self;
        _tableView.delegate = self;
        _tableView.sectionHeaderHeight = 0;
        _tableView.backgroundColor = [UIColor colorWithRed:243.0/255 green:243.0/255 blue:243.0/255 alpha:1];
        _tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
    }
    return _tableView;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 50;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if(section == 0){
        return _array.count;
    }else if (section == 1){
        return _arraytwo.count;
    }
    return 0;
}

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 2;
}

- (UITableViewCell *)tableView:(UITableView *)tableView
         cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString *reuseIdentifer = @"cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:reuseIdentifer];
    if(!cell){
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuseIdentifer];
    }
    
    if(indexPath.section == 0){
        cell.textLabel.text = _array[indexPath.row];
        //右侧箭头
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    }else if (indexPath.section == 1){
        cell.textLabel.text = _arraytwo[indexPath.row];
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    }
    return cell;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
    //无背景阴影
    [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
    
    if(indexPath.section == 0)
    {
        if(indexPath.row == 0)
        {
            NSLog(@"这是第一个");
            ChangePasswordViewController *changepassword = [[ChangePasswordViewController alloc] init];
            [self presentViewController:changepassword animated:YES completion:nil];
            
        }else if (indexPath.row == 1){
            UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Sign In Password"
                                                                message:@"Please Input Your Sign In Password"
                                                               delegate:self
                                                  cancelButtonTitle:@"Cancel"
                                                      otherButtonTitles:@"Confirm", nil];
            
            [alert setAlertViewStyle:UIAlertViewStylePlainTextInput];
            textPass = [alert textFieldAtIndex:0];
            textPass.secureTextEntry = YES;
            [alert show];
            
        }else if (indexPath.row == 2){
            UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Sign In Password"
                                                            message:@"Please Input Your Sign In Password"
                                                           delegate:self
                                                  cancelButtonTitle:@"Cancel"
                                                  otherButtonTitles:@"Confirm", nil];
            [alert show];

        }
    }else if (indexPath.section == 1){
        NSLog(@"section2");
    }
}
@end


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值