您的位置:首页 > 其它

TableView cell section TextField ALert

2017-08-03 10:48 375 查看
主要功能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"

9152
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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: