添加联系人界面
来源:互联网 发布:陪我聊天软件 编辑:程序博客网 时间:2024/04/30 11:02
#import "FYZAddAddressPersonController.h"#import "AddAddressPersonView.h"#import "DXAlertView.h"#import "FYZPhotoLibraryController.h"#import "FYZAddressBookNavigationController.h"@interface FYZAddAddressPersonController ()<UIScrollViewDelegate, FYZPhotoLibraryControllerDelegate>{ BOOL _isSave; //标识用户是否保存}@property (nonatomic, copy) NSString *imageName;//存储点击的图片名字@end@implementation FYZAddAddressPersonController- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil{ self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { // Custom initialization _isSave = NO; } return self;}- (void)loadView{ AddAddressPersonView *addView = [[AddAddressPersonView alloc] initWithFrame:[UIScreen mainScreen].bounds]; addView.delegate = self; self.view = addView; //为头像添加轻拍手势 UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTap:)]; [addView.avatarView addGestureRecognizer:tap]; RELEASE_SAFE(tap); RELEASE_SAFE(addView);}- (void)scrollViewDidScroll:(UIScrollView *)scrollView{ if (0 != scrollView.frame.origin.y) { [(AddAddressPersonView *)scrollView resignKeyboard]; [UIView animateWithDuration:0.25 animations:^{ scrollView.frame = [UIScreen mainScreen].bounds; }]; }}- (void)viewDidLoad{ [super viewDidLoad]; // Do any additional setup after loading the view. self.view.backgroundColor = [UIColor lightWhiteColor]; [self customizeNavigationBarContent];}- (void)customizeNavigationBarContent{ //titleView UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 100, 40)]; titleLabel.text = @"添加联系人"; titleLabel.textColor = [UIColor whiteColor]; titleLabel.textAlignment = NSTextAlignmentCenter; self.navigationItem.titleView = titleLabel; RELEASE_SAFE(titleLabel); //leftItem UIBarButtonItem *leftItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"clsose"] style:UIBarButtonItemStylePlain target:self action:@selector(handleBack:)]; self.navigationItem.leftBarButtonItem = leftItem; RELEASE_SAFE(leftItem); //rightItem UIBarButtonItem *rightItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"doneR"] style:UIBarButtonItemStylePlain target:self action:@selector(handleSave:)]; self.navigationItem.rightBarButtonItem = rightItem; RELEASE_SAFE(rightItem);}#pragma mark - handleTap- (void)handleTap:(UIGestureRecognizer *)tap{ //模态出图库界面 FYZPhotoLibraryController *photoVC = [[FYZPhotoLibraryController alloc] initWithStyle:UITableViewStylePlain]; //设置代理 photoVC.delegate = self; FYZAddressBookNavigationController *navigationVC = [[FYZAddressBookNavigationController alloc] initWithRootViewController:photoVC]; [self presentViewController:navigationVC animated:YES completion:nil]; RELEASE_SAFE(photoVC); RELEASE_SAFE(navigationVC);}#pragma mark - handle Action- (void)handleBack:(UIBarButtonItem *)item{ [(AddAddressPersonView *)self.view resignKeyboard]; [UIView animateWithDuration:0.25 animations:^{ self.view.frame = [UIScreen mainScreen].bounds; }]; //判断用户是否保存,如果用户没有保存,警告用户是否保存. if (!_isSave) { //没有保存警告用户是否保存 DXAlertView *alert = [[DXAlertView alloc] initWithTitle:@"危险" contentText:@"您还没有保存,确定返回?" leftButtonTitle:@"取消" rightButtonTitle:@"确定"]; [alert show]; //__block 防止block对视图控制器对象retain. __block FYZAddAddressPersonController *vc = self; alert.rightBlock = ^() { [vc dismissViewControllerAnimated:YES completion:nil]; }; RELEASE_SAFE(alert); return; }}- (void)handleSave:(UIBarButtonItem *)item{ _isSave = YES; //已经保存 //创建person对象来接收self.view传过来的要添加的对象 AddressPerson *person = [(AddAddressPersonView *)self.view addAddressonPerson]; //给封装好的对象添加图片名 //person.imageName = self.imageName; if (!self.imageName) { person.imageName = @"grassGreen_avatarEmpty@2x"; } else { person.imageName = self.imageName; } if (![person.name isEqualToString:@""] && ![person.phoneNumber isEqualToString:@""]) { //修改数据源(让通讯录列表界面添加) [FYZAddressBookHelper addAddresPerson:person]; } [self dismissViewControllerAnimated:YES completion:nil];}#pragma mark - UIAlertViewDelegate- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{ switch (buttonIndex) { case 1: //如果点击确定,直接返回上一界面 [self dismissViewControllerAnimated:YES completion:nil]; break; default: break; }}#pragma mark - system- (void)didReceiveMemoryWarning{ [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated.}#pragma mark - FYZPhotoLibraryControllerDelegate- (void)didSelectPhotoWithPhotoName:(NSString *)photoName{ //保存点击的图片名字 self.imageName = photoName; //将头像换成更改之后的图片 AddAddressPersonView *view = (AddAddressPersonView *)self.view; view.avatarView.image = [UIImage imageNamed:photoName];}- (void)dealloc{ RELEASE_SAFE(_imageName); [super dealloc];}@end
0 0
- 添加联系人界面
- 【Contacts】联系人界面添加联系人统计项
- 联系人添加界面并添加相应数据
- 调用系统联系人的添加界面-android
- android调用系统添加联系人界面
- 调用系统添加联系人界面的套路
- 高仿微信发起群聊添加联系人界面
- Android 调用系统联系人界面的添加联系人,添加已有联系人,编辑和修改。
- android 短信下,添加联系人,进入联系人多选界面出现联系人电话号码晃动的问题
- 调用联系人添加界面并添加一条联系信息(包括联系人姓名、电话号码、email、公司名称)
- 转到编辑联系人的系统界面 编辑 添加
- 向Android系统自带的联系人界面添加数据
- 向Android系统自带的联系人界面添加数据
- Android添加数据到系统自带的联系人界面
- android 从项目中调用系统添加联系人界面
- android通过Intent跳转到添加联系人界面的小结
- Dynamics CRM 2013 SP1 客户表单界面上联系人subgrid上的添加现有联系人功能缺失
- 启动系统联系人界面
- java Android虚拟机启动失败的解决方法
- Combination Sum Problem - A Non-recursive Method
- 【docker】docker镜像关系图
- iOS归档与解归档,持久化存储
- 通讯录
- 添加联系人界面
- N-Queens Problem
- 利用fileupload组件在项目中实现上传
- Top N Numbers
- 虚函数表的实现细节
- addressBookHelper
- 关于Dialog使用上下文的问题
- Unix Socket编程简介
- Myeclipse试用到期解决方法