加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
ContactDetailViewController.m 11.15 KB
一键复制 编辑 原始数据 按行查看 历史
xiexiaolong.xxl 提交于 2024-06-18 15:06 . init
//
// ContactDetailViewController.m
// officeMobile
//
// Created by Points on 15-3-12.
// Copyright (c) 2015年 com.kinggrid. All rights reserved.
//
#import "ContactDetailViewController.h"
#import "FontSizeUtil.h"
@interface ContactDetailViewController ()<UITableViewDataSource,UITableViewDelegate>
@end
@implementation ContactDetailViewController
- (id)initWith:(ADTContacterInfo *)contactInfo
{
self.m_contactInfo = contactInfo;
if(self = [super initWithStyle:UITableViewStylePlain withIsNeedPullDown:NO withIsNeedPullUpLoadMore:NO withIsNeedBottobBar:NO])
{
self.tableView.dataSource = self;
self.tableView.delegate = self;
[self.tableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];
}
return self;
}
- (void)viewDidLoad {
[super viewDidLoad];
[title setText:self.m_contactInfo.m_strUserName];
[self reloadDeals];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark - TableViewDelegate
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 40;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 8;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString * identify = @"spe";
UITableViewCell * cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identify];
UIView *sep = [[UIView alloc]initWithFrame:CGRectMake(0, 39.5, MAIN_WIDTH, 0.5)];
[sep setBackgroundColor:[UIColor grayColor]];
sep.alpha = 0.3;
[cell.contentView addSubview:sep];
if(indexPath.row == 0)
{
CGSize size = [FontSizeUtil sizeOfString:@"姓名:" withFont:[UIFont systemFontOfSize:14]];
UILabel *titleLab = [[UILabel alloc]initWithFrame:CGRectMake(10, 10,size.width, size.height)];
[titleLab setFont:[UIFont systemFontOfSize:14]];
[titleLab setText:@"姓名:"];
[cell.contentView addSubview:titleLab];
UILabel *contentLab = [[UILabel alloc]initWithFrame:CGRectMake(size.width+10, 10,MAIN_WIDTH-size.width-10, size.height)];
[contentLab setFont:[UIFont systemFontOfSize:14]];
[contentLab setText:self.m_contactInfo.m_strUserName];
[cell.contentView addSubview:contentLab];
}
else if (indexPath.row == 4)
{
CGSize size = [FontSizeUtil sizeOfString:@"电话短号:" withFont:[UIFont systemFontOfSize:14]];
UILabel *titleLab = [[UILabel alloc]initWithFrame:CGRectMake(10, 10,size.width, size.height)];
[titleLab setFont:[UIFont systemFontOfSize:14]];
[titleLab setText:@"电话短号:"];
[cell.contentView addSubview:titleLab];
UILabel *contentLab = [[UILabel alloc]initWithFrame:CGRectMake(size.width+10, 10,MAIN_WIDTH-size.width-10, size.height)];
[contentLab setFont:[UIFont systemFontOfSize:14]];
[contentLab setText:self.m_contactInfo.m_strMobileShort];
[cell.contentView addSubview:contentLab];
} else if (indexPath.row == 5)
{
CGSize size = [FontSizeUtil sizeOfString:@"手机短号:" withFont:[UIFont systemFontOfSize:14]];
UILabel *titleLab = [[UILabel alloc]initWithFrame:CGRectMake(10, 10,size.width, size.height)];
[titleLab setFont:[UIFont systemFontOfSize:14]];
[titleLab setText:@"手机短号:"];
[cell.contentView addSubview:titleLab];
UILabel *contentLab = [[UILabel alloc]initWithFrame:CGRectMake(size.width+10, 10,MAIN_WIDTH-size.width-10, size.height)];
[contentLab setFont:[UIFont systemFontOfSize:14]];
[contentLab setText:self.m_contactInfo.m_strTelShort];
[cell.contentView addSubview:contentLab];
} else if (indexPath.row == 6)
{
CGSize size = [FontSizeUtil sizeOfString:@"电话2:" withFont:[UIFont systemFontOfSize:14]];
UILabel *titleLab = [[UILabel alloc]initWithFrame:CGRectMake(10, 10,size.width, size.height)];
[titleLab setFont:[UIFont systemFontOfSize:14]];
[titleLab setText:@"电话2:"];
[cell.contentView addSubview:titleLab];
UILabel *contentLab = [[UILabel alloc]initWithFrame:CGRectMake(size.width+10, 10,MAIN_WIDTH-size.width-10, size.height)];
[contentLab setFont:[UIFont systemFontOfSize:14]];
[contentLab setText:self.m_contactInfo.m_strTel2];
[cell.contentView addSubview:contentLab];
}
else if (indexPath.row == 7)
{
CGSize size = [FontSizeUtil sizeOfString:@"邮箱:" withFont:[UIFont systemFontOfSize:14]];
UILabel *titleLab = [[UILabel alloc]initWithFrame:CGRectMake(10, 10,size.width, size.height)];
[titleLab setFont:[UIFont systemFontOfSize:14]];
[titleLab setText:@"邮箱:"];
[cell.contentView addSubview:titleLab];
UILabel *contentLab = [[UILabel alloc]initWithFrame:CGRectMake(size.width+10, 10,MAIN_WIDTH-size.width-10, size.height)];
[contentLab setFont:[UIFont systemFontOfSize:14]];
[contentLab setText:self.m_contactInfo.m_strEmail];
[cell.contentView addSubview:contentLab];
}
else if (indexPath.row == 2)
{
CGSize size = [FontSizeUtil sizeOfString:@"手机号码:" withFont:[UIFont systemFontOfSize:14]];
UILabel *titleLab = [[UILabel alloc]initWithFrame:CGRectMake(10, 10,size.width, size.height)];
[titleLab setFont:[UIFont systemFontOfSize:14]];
[titleLab setText:@"手机号码:"];
[cell.contentView addSubview:titleLab];
if(self.m_contactInfo.m_strMobile.length > 0){
UIButton *telBtn = [UIButton buttonWithType:UIButtonTypeCustom];
[telBtn.titleLabel setTextAlignment:NSTextAlignmentLeft];
[telBtn.titleLabel setFont:[UIFont systemFontOfSize:13]];
telBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
[telBtn addTarget:self action:@selector(telBtnClicked2) forControlEvents:UIControlEventTouchUpInside];
[telBtn setFrame:CGRectMake(CGRectGetMaxX(titleLab.frame)+10, 10,MAIN_WIDTH-size.width-10, size.height)];
[telBtn setTitle:self.m_contactInfo.m_strMobile forState:UIControlStateNormal];
[telBtn setTitleColor:KEY_COMMON_CORLOR forState:UIControlStateNormal];
[cell.contentView addSubview:telBtn];
UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
[btn addTarget:self action:@selector(telBtnClicked) forControlEvents:UIControlEventTouchUpInside];
[btn setFrame:CGRectMake(MAIN_WIDTH-50, 2, 36, 36)];
[btn setImageEdgeInsets:UIEdgeInsetsMake(10,10,10, 10)];
[btn setImage:[UIImage imageNamed:@"phone"] forState:UIControlStateNormal];
// btn.layer.cornerRadius = 4;
// btn.layer.borderColor = [UIColor grayColor].CGColor;
// btn.layer.borderWidth = 0.5;
// [btn setTitle:@"短信" forState:UIControlStateNormal];
// [btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
[cell.contentView addSubview:btn];
}
}
else if (indexPath.row == 3)
{
CGSize size = [FontSizeUtil sizeOfString:@"电话号码:" withFont:[UIFont systemFontOfSize:14]];
UILabel *titleLab = [[UILabel alloc]initWithFrame:CGRectMake(10, 10,size.width, size.height)];
[titleLab setFont:[UIFont systemFontOfSize:14]];
[titleLab setText:@"电话号码:"];
[cell.contentView addSubview:titleLab];
if(self.m_contactInfo.m_strTel.length > 0){
UIButton *telBtn = [UIButton buttonWithType:UIButtonTypeCustom];
[telBtn.titleLabel setTextAlignment:NSTextAlignmentLeft];
[telBtn.titleLabel setFont:[UIFont systemFontOfSize:13]];
telBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
[telBtn addTarget:self action:@selector(smsBtnClicked) forControlEvents:UIControlEventTouchUpInside];
[telBtn setFrame:CGRectMake(CGRectGetMaxX(titleLab.frame)+10, 10,MAIN_WIDTH-size.width-10, size.height)];
[telBtn setTitle:self.m_contactInfo.m_strTel forState:UIControlStateNormal];
[telBtn setTitleColor:KEY_COMMON_CORLOR forState:UIControlStateNormal];
[cell.contentView addSubview:telBtn];
UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
[btn addTarget:self action:@selector(smsBtnClicked2) forControlEvents:UIControlEventTouchUpInside];
[btn setFrame:CGRectMake(MAIN_WIDTH-50, 2, 36, 36)];
[btn setImageEdgeInsets:UIEdgeInsetsMake(10,10,10, 10)];
[btn setImage:[UIImage imageNamed:@"phone"] forState:UIControlStateNormal];
// btn.layer.cornerRadius = 4;
// btn.layer.borderColor = [UIColor grayColor].CGColor;
// btn.layer.borderWidth = 0.5;
// [btn setTitle:@"短信" forState:UIControlStateNormal];
// [btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
[cell.contentView addSubview:btn];
}
// UILabel *contentLab = [[UILabel alloc]initWithFrame:CGRectMake(size.width+40, 10,MAIN_WIDTH-size.width-10, size.height)];
// [contentLab setTextColor:KEY_COMMON_CORLOR];
// [contentLab setFont:[UIFont systemFontOfSize:16]];
// [contentLab setText:self.m_contactInfo.m_strTel];
// [cell.contentView addSubview:contentLab];
}
else if(indexPath.row == 1)
{
CGSize size = [FontSizeUtil sizeOfString:@"职务:" withFont:[UIFont systemFontOfSize:14]];
UILabel *titleLab = [[UILabel alloc]initWithFrame:CGRectMake(10, 10,size.width, size.height)];
[titleLab setFont:[UIFont systemFontOfSize:14]];
[titleLab setText:@"职务:"];
[cell.contentView addSubview:titleLab];
UILabel *contentLab = [[UILabel alloc]initWithFrame:CGRectMake(size.width+10, 10,MAIN_WIDTH-size.width-10, size.height)];
[contentLab setText:self.m_contactInfo.m_strJob];
[contentLab setFont:[UIFont systemFontOfSize:14]];
[cell.contentView addSubview:contentLab];
}
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
}
- (void)smsBtnClicked
{
if(self.m_contactInfo.m_strTel.length > 0)
{
[[UIApplication sharedApplication]openURL:[NSURL URLWithString:[NSString stringWithFormat:@"tel://%@",self.m_contactInfo.m_strTel]]];
}
}
- (void)smsBtnClicked2
{
if(self.m_contactInfo.m_strTel.length > 0)
{
[[UIApplication sharedApplication]openURL:[NSURL URLWithString:[NSString stringWithFormat:@"tel://%@",self.m_contactInfo.m_strTel]]];
}
}
- (void)telBtnClicked
{
if(self.m_contactInfo.m_strMobile.length > 0)
{
[[UIApplication sharedApplication]openURL:[NSURL URLWithString:[NSString stringWithFormat:@"tel://%@",self.m_contactInfo.m_strMobile]]];
}
}
- (void)telBtnClicked2
{
if(self.m_contactInfo.m_strMobile.length > 0)
{
[[UIApplication sharedApplication]openURL:[NSURL URLWithString:[NSString stringWithFormat:@"sms://%@",self.m_contactInfo.m_strMobile]]];
}
}
@end
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化