03通讯录

 03-小码哥通讯录(登录界面)

//  XMGLoginViewController.m
//  小码哥通讯录
#import "XMGLoginViewController.h"

@interface XMGLoginViewController ()<UITextFieldDelegate>
@property (weak, nonatomic) IBOutlet UIButton *loginBtn;

@property (weak, nonatomic) IBOutlet UITextField *accountField;
@property (weak, nonatomic) IBOutlet UITextField *pwdField;

@property (weak, nonatomic) IBOutlet UISwitch *rmbPwdSwitch;
@property (weak, nonatomic) IBOutlet UISwitch *autoLoginSwitch;
@end

@implementation XMGLoginViewController

// 记住密码开关状态改变的时候调用
- (IBAction)rmbPwdChange:(id)sender {
    // 如果取消记住密码,自动登录也需要取消勾选

    if (_rmbPwdSwitch.on == NO) { // 取消记住密码
        // 取消自动登录
        [_autoLoginSwitch setOn:NO animated:YES];
    }

}

// 自动登录开关状态改变的时候调用
- (IBAction)autoLoginChange:(id)sender {

    // 如果勾选了自动登录,记住密码也要勾选
    if (_autoLoginSwitch.on == YES) {
        [_rmbPwdSwitch setOn:YES animated:YES];

    }

}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.

    // 监听文本框是否有内容
//    _accountField.delegate = self;

    // 给文本框添加监听器,及时监听文本框内容的改变
    [_accountField addTarget:self action:@selector(textChange) forControlEvents:UIControlEventEditingChanged];
    [_pwdField addTarget:self action:@selector(textChange) forControlEvents:UIControlEventEditingChanged];

}

// 任一一个文本框的内容改变都会调用
- (void)textChange
{

    _loginBtn.enabled = _accountField.text.length && _pwdField.text.length;
    NSLog(@"%@--%@",_accountField.text,_pwdField.text);
}

// 当用户输入的时候就会调用,判断下用户是否允许输入
// 及时的判断文本框有没有内容
// 注意这个方法不能及时获取文本框的内容
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{

    NSLog(@"%@",_accountField.text);

    return YES;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end

 04-小码哥通讯录(登录功能)

//
//  XMGLoginViewController.m
//  小码哥通讯录
#import "XMGLoginViewController.h"

#import "MBProgressHUD+XMG.h"

@interface XMGLoginViewController ()<UITextFieldDelegate>
@property (weak, nonatomic) IBOutlet UIButton *loginBtn;

@property (weak, nonatomic) IBOutlet UITextField *accountField;
@property (weak, nonatomic) IBOutlet UITextField *pwdField;

@property (weak, nonatomic) IBOutlet UISwitch *rmbPwdSwitch;
@property (weak, nonatomic) IBOutlet UISwitch *autoLoginSwitch;
@end

@implementation XMGLoginViewController
// 点击了登录按钮的时候调用
// xmg 123
- (IBAction)login:(id)sender {

    // 提示用户,正在登录ing...
    [MBProgressHUD showMessage:@"正在登录ing..."];

    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{

        // 隐藏蒙版
        [MBProgressHUD hideHUD];

        // 验证下账号和密码是否正确
        if ([_accountField.text isEqualToString:@"xmg"] && [_pwdField.text isEqualToString:@"123"]) { // 输入正确

            // 直接跳转
            // 跳转到联系人界面
            [self performSegueWithIdentifier:@"login2Contact" sender:nil];

        }else{ // 账号或者密码错误

            // 提示用户账号或者密码错误
            [MBProgressHUD showError:@"账号或者密码错误"];

        }

    });

}

// 记住密码开关状态改变的时候调用
- (IBAction)rmbPwdChange:(id)sender {
    // 如果取消记住密码,自动登录也需要取消勾选

    if (_rmbPwdSwitch.on == NO) { // 取消记住密码
        // 取消自动登录
        [_autoLoginSwitch setOn:NO animated:YES];
    }

}

// 自动登录开关状态改变的时候调用
- (IBAction)autoLoginChange:(id)sender {

    // 如果勾选了自动登录,记住密码也要勾选
    if (_autoLoginSwitch.on == YES) {
        [_rmbPwdSwitch setOn:YES animated:YES];

    }

}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.

    // 监听文本框是否有内容
//    _accountField.delegate = self;

    // 给文本框添加监听器,及时监听文本框内容的改变
    [_accountField addTarget:self action:@selector(textChange) forControlEvents:UIControlEventEditingChanged];
    [_pwdField addTarget:self action:@selector(textChange) forControlEvents:UIControlEventEditingChanged];

}

// 任一一个文本框的内容改变都会调用
- (void)textChange
{

    _loginBtn.enabled = _accountField.text.length && _pwdField.text.length;
    NSLog(@"%@--%@",_accountField.text,_pwdField.text);
}

// 当用户输入的时候就会调用,判断下用户是否允许输入
// 及时的判断文本框有没有内容
// 注意这个方法不能及时获取文本框的内容
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{

    NSLog(@"%@",_accountField.text);

    return YES;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
//
//  XMGContactViewController.m
//  小码哥通讯录
#import "XMGContactViewController.h"

@interface XMGContactViewController ()<UIActionSheetDelegate>

@end

@implementation XMGContactViewController

// 点击注销的时候调用
- (IBAction)logout:(id)sender {

    // 弹出actionSheet
    UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:@"是否注销?" delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:@"注销" otherButtonTitles:nil, nil];

    [sheet showInView:self.view];

}
#pragma mark - UIActionSheetDelegate
// 点击UIActionSheet控件上的按钮调用
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
    if (buttonIndex == 0) { // 点击了注销

        [self.navigationController popViewControllerAnimated:YES];

    }

}

- (void)viewDidLoad {
    [super viewDidLoad];

    // Uncomment the following line to preserve selection between presentations.
    // self.clearsSelectionOnViewWillAppear = NO;

    // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
    // self.navigationItem.rightBarButtonItem = self.editButtonItem;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
#warning Potentially incomplete method implementation.
    // Return the number of sections.
    return 0;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
#warning Incomplete method implementation.
    // Return the number of rows in the section.
    return 0;
}

/*
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:<#@"reuseIdentifier"#> forIndexPath:indexPath];

    // Configure the cell...

    return cell;
}
*/

/*
// Override to support conditional editing of the table view.
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return NO if you do not want the specified item to be editable.
    return YES;
}
*/

/*
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
    if (editingStyle == UITableViewCellEditingStyleDelete) {
        // Delete the row from the data source
        [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
    } else if (editingStyle == UITableViewCellEditingStyleInsert) {
        // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
    }
}
*/

/*
// Override to support rearranging the table view.
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
}
*/

/*
// Override to support conditional rearranging of the table view.
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return NO if you do not want the item to be re-orderable.
    return YES;
}
*/

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end

05-小码哥通讯录(顺传)

//
//  XMGLoginViewController.m
//  小码哥通讯录
#import "XMGLoginViewController.h"

#import "MBProgressHUD+XMG.h"

@interface XMGLoginViewController ()<UITextFieldDelegate>
@property (weak, nonatomic) IBOutlet UIButton *loginBtn;

@property (weak, nonatomic) IBOutlet UITextField *accountField;
@property (weak, nonatomic) IBOutlet UITextField *pwdField;

@property (weak, nonatomic) IBOutlet UISwitch *rmbPwdSwitch;
@property (weak, nonatomic) IBOutlet UISwitch *autoLoginSwitch;
@end
/*
 来源控制器传递给目的控制器:顺传
 数据传值:
 1.接收方一定要有属性接收
 2.传递方必须要拿到接收方

 */

/*
 1.[self performSegueWithIdentifier]
 2.创建segue
 3.设置来源控制器segue.sourceViewController = self
 4.创建目的控制器,segue.destinationViewController = 目的控制器
 5.[self prepareForSegue]跳转之前的准备操作
 6.[segue perform]
 7.判断下segue的类型,如果是push,拿到导航控制器push
 [self.navigationController pushViewController:segue.destinationViewController animated:YES];
 */
@implementation XMGLoginViewController

// 在执行跳转之前的时候调用
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{

    UIViewController *vc = segue.destinationViewController;
    vc.title = [NSString stringWithFormat:@"%@的联系人列表", _accountField.text];
    NSLog(@"%@--%@",segue.sourceViewController,segue.destinationViewController);
}

// 点击了登录按钮的时候调用
// xmg 123
- (IBAction)login:(id)sender {

    // 提示用户,正在登录ing...
    [MBProgressHUD showMessage:@"正在登录ing..."];

    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{

        // 隐藏蒙版
        [MBProgressHUD hideHUD];

        // 验证下账号和密码是否正确
        if ([_accountField.text isEqualToString:@"xmg"] && [_pwdField.text isEqualToString:@"123"]) { // 输入正确

            // 直接跳转
            // 跳转到联系人界面
            [self performSegueWithIdentifier:@"login2Contact" sender:nil];

        }else{ // 账号或者密码错误

            // 提示用户账号或者密码错误
            [MBProgressHUD showError:@"账号或者密码错误"];

        }

    });

}

// 记住密码开关状态改变的时候调用
- (IBAction)rmbPwdChange:(id)sender {
    // 如果取消记住密码,自动登录也需要取消勾选

    if (_rmbPwdSwitch.on == NO) { // 取消记住密码
        // 取消自动登录
        [_autoLoginSwitch setOn:NO animated:YES];
    }

}

// 自动登录开关状态改变的时候调用
- (IBAction)autoLoginChange:(id)sender {

    // 如果勾选了自动登录,记住密码也要勾选
    if (_autoLoginSwitch.on == YES) {
        [_rmbPwdSwitch setOn:YES animated:YES];

    }

}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.

    // 给文本框添加监听器,及时监听文本框内容的改变
    [_accountField addTarget:self action:@selector(textChange) forControlEvents:UIControlEventEditingChanged];
    [_pwdField addTarget:self action:@selector(textChange) forControlEvents:UIControlEventEditingChanged];

}

// 任一一个文本框的内容改变都会调用
- (void)textChange
{
    _loginBtn.enabled = _accountField.text.length && _pwdField.text.length;
    NSLog(@"%@--%@",_accountField.text,_pwdField.text);
}

@end
//
//  XMGContactViewController.m
//  小码哥通讯录
#import "XMGContactViewController.h"

@interface XMGContactViewController ()<UIActionSheetDelegate>

@end

@implementation XMGContactViewController

// 点击注销的时候调用
- (IBAction)logout:(id)sender {

    // 弹出actionSheet
    UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:@"是否注销?" delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:@"注销" otherButtonTitles:nil, nil];

    [sheet showInView:self.view];

}
#pragma mark - UIActionSheetDelegate
// 点击UIActionSheet控件上的按钮调用
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
    if (buttonIndex == 0) { // 点击了注销

        [self.navigationController popViewControllerAnimated:YES];

    }

}

- (void)viewDidLoad {
    [super viewDidLoad];

    // Uncomment the following line to preserve selection between presentations.
    // self.clearsSelectionOnViewWillAppear = NO;

    // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
    // self.navigationItem.rightBarButtonItem = self.editButtonItem;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
#warning Potentially incomplete method implementation.
    // Return the number of sections.
    return 0;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
#warning Incomplete method implementation.
    // Return the number of rows in the section.
    return 0;
}

/*
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:<#@"reuseIdentifier"#> forIndexPath:indexPath];

    // Configure the cell...

    return cell;
}
*/

/*
// Override to support conditional editing of the table view.
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return NO if you do not want the specified item to be editable.
    return YES;
}
*/

/*
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
    if (editingStyle == UITableViewCellEditingStyleDelete) {
        // Delete the row from the data source
        [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
    } else if (editingStyle == UITableViewCellEditingStyleInsert) {
        // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
    }
}
*/

/*
// Override to support rearranging the table view.
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
}
*/

/*
// Override to support conditional rearranging of the table view.
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return NO if you do not want the item to be re-orderable.
    return YES;
}
*/

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
时间: 2024-11-09 04:38:28

03通讯录的相关文章

03通讯录(搭建编辑界面)

// // XMGContactViewController.h // 小码哥通讯录 #import <UIKit/UIKit.h> @class XMGContact; @interface XMGContactViewController : UITableViewController @end // // XMGContactViewController.m // 小码哥通讯录// #import "XMGContactViewController.h" #impor

03通讯录(逆传)

// // XMGLoginViewController.m // 小码哥通讯录 #import "XMGLoginViewController.h" #import "MBProgressHUD+XMG.h" @interface XMGLoginViewController ()<UITextFieldDelegate> @property (weak, nonatomic) IBOutlet UIButton *loginBtn; @propert

【Android 仿微信通讯录 导航分组列表-上】使用ItemDecoration为RecyclerView打造带悬停头部的分组列表

[Android 仿微信通讯录 导航分组列表-上]使用ItemDecoration为RecyclerView打造带悬停头部的分组列表 一 概述 本文是Android导航分组列表系列上,因时间和篇幅原因分上下,最终上下合璧,完整版效果如下: 上部残卷效果如下:两个ItemDecoration,一个实现悬停头部分组列表功能,一个实现分割线(官方demo) 网上关于实现带悬停分组头部的列表的方法有很多,像我看过有主席的自定义ExpandListView实现的,也看过有人用一个额外的父布局里面套 Rec

11-1. 通讯录的录入与显示(10)

通讯录中的一条记录包含下述基本信息:朋友的姓名.出生日期.性别.固定电话号码.移动电话号码. 本题要求编写程序,录入N条记录,并且根据要求显示任意某条记录. 输入格式: 输入在第1行给出正整数N(<=10):随后N行,每行按照格式“姓名 生日 性别 固话 手机”给出一条记录.其中“姓名”是不超过10个字符.不包含空格的非空字符串:生日按“yyyy/mm/dd”的格式给出年月日:性别用“M”表示“男”.“F”表示“女”:“固话”和“手机”均为不超过15位的连续数字,前面有可能出现“+”. 在通讯录

通讯录 ios如何使用iOS AddressBook

一.基本知识 和通讯录中联系人相关的应用iPhone提供了两个框架:AddressBook.framework和AddressBookUI.framework,使用这两个框架我们可以在程序中访问并显示iPhone数据库中的联系人信息. 二.具体介绍 1.AddressBookUI显示部分 AddressBookUI中提供了和联系人显示信息相关的一些Controller,有四个: ABPeoplePickerNavigationController:显示整个通讯录并可以选择一个联系人的信息 ABP

结构-04. 通讯录的录入与显示(10)

通讯录中的一条记录包含下述基本信息:朋友的姓名.出生日期.性别.固定电话号码.移动电话号码. 本题要求编写程序,录入N条记录,并且根据要求显示任意某条记录. 输入格式: 输入在第1行给出正整数N(<=10):随后N行,每行按照格式“姓名 生日 性别 固话 手机”给出一条记录.其中“姓名”是不超过10个字符.不包含空格的非空字符串:生日按“yyyy/mm/dd”的格式给出年月日:性别用“M”表示“男”.“F”表示“女”:“固话”和“手机”均为不超过15位的连续数字,前面有可能出现“+”. 在通讯录

03微信公众平台 - 实现【天气查询】功能函数,返回一个文本字符串。

一.功能代码函数实现 private function _weather($city) { include("weather_cityId.php"); $c_name=$weather_cityId[$city]; if(!empty($c_name)){ $json=file_get_contents("http://m.weather.com.cn/data/".$c_name.".html"); $data = json_decode($

iOS -------- 应用程序引用系统通讯录

转自:http://www.cnblogs.com/ygm900/p/3472288.html 由于ios系统对用户隐私的控制,第三方应用程序只能通过苹果官方接口调用系统通讯录,不能像android那样直接操作通讯录数据库.     一般地,使用系统自带通讯录的方法有两种,一种是直接将整个通讯录引入到应用程序,另一种是逐条读取通讯录中的每一条联系人信息.下面我们就一一详解. 1 直接引用整个通讯录 使用的类:ABPeoplePickerNavigationController方法: 在Local

通讯录的录入与显示

通讯录中的一条记录包含下述基本信息:朋友的姓名.出生日期.性别.固定电话号码.移动电话号码.本题要求编写程序,录入N条记录,并且根据要求显示任意某条记录. 输入格式: 输入在第1行给出正整数N(<=10):随后N行,每行按照格式“姓名 生日 性别 固话 手机”给出一条记录.其中“姓名”是不超过10个字符.不包含空格的非空字符串:生日按“yyyy/mm/dd”的格式给出年月日:性别用“M”表示“男”.“F”表示“女”:“固话”和“手机”均为不超过15位的连续数字,前面有可能出现“+”. 在通讯录记