ContactDetailVC.m 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. //
  2. // ContactDetailVC.m
  3. // 通讯录
  4. //
  5. // Created by EchoShacolee on 2017/5/22.
  6. // Copyright © 2017年 lee. All rights reserved.
  7. //
  8. #import "ContactDetailVC.h"
  9. #import "ContactTableViewCell.h"
  10. @interface ContactDetailVC ()<UITableViewDataSource,UITableViewDelegate>
  11. @end
  12. @implementation ContactDetailVC
  13. - (void)viewDidLoad {
  14. [super viewDidLoad];
  15. [self myInit];
  16. }
  17. - (void)didReceiveMemoryWarning {
  18. [super didReceiveMemoryWarning];
  19. // Dispose of any resources that can be recreated.
  20. }
  21. -(void)myInit{
  22. [self goBackByNavigation];
  23. UITableView * tableview = [[UITableView alloc]initWithFrame:kFrame style:UITableViewStylePlain];
  24. tableview.delegate = self;
  25. tableview.dataSource = self;
  26. tableview.showsVerticalScrollIndicator = NO;
  27. tableview.tableFooterView = [UIView new];
  28. [self.view addSubview:tableview];
  29. }
  30. #pragma mark tableview代理相关
  31. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  32. return [_oneDetail count];
  33. }
  34. -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  35. if (indexPath.row == 0) {
  36. return 150;
  37. }
  38. return 50;
  39. }
  40. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  41. if (indexPath.row == 0) {
  42. UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"xx"];
  43. if (!cell) {
  44. cell = [[UITableViewCell alloc]initWithStyle:0 reuseIdentifier:@"xx"];
  45. }
  46. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  47. CGFloat x,y,w,h;
  48. w = h = 80;
  49. x = (kSize.width-w)/2;
  50. y = 10;
  51. UILabel * topLab = [[UILabel alloc]initWithFrame:CGRectMake(x, y, w, h)];
  52. topLab.text = [self.oneDetail[0] substringToIndex:1];
  53. topLab.textAlignment = NSTextAlignmentCenter;
  54. topLab.backgroundColor = [UIColor lightGrayColor];
  55. topLab.textColor = [UIColor whiteColor];
  56. topLab.layer.cornerRadius = w/2;
  57. topLab.layer.masksToBounds = YES;
  58. topLab.font = [UIFont systemFontOfSize:45];
  59. [cell.contentView addSubview:topLab];
  60. x = 0;
  61. y += h+10;
  62. w = kSize.width;
  63. h = 50;
  64. UILabel * titleLab = [[UILabel alloc]initWithFrame:CGRectMake(x, y, w, h)];
  65. titleLab.text = self.oneDetail[0];
  66. titleLab.textAlignment = NSTextAlignmentCenter;
  67. titleLab.textColor = [UIColor blackColor];
  68. titleLab.font = [UIFont systemFontOfSize:30];//[UIFont fontWithName:@"Helvetica-Bold" size:30]
  69. // cell.contentView.backgroundColor =
  70. [cell.contentView addSubview:titleLab];
  71. return cell;
  72. }
  73. ContactTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cellID"];
  74. if (!cell) {
  75. cell = [[[NSBundle mainBundle] loadNibNamed:@"ContactTableViewCell" owner:nil options:nil]lastObject];
  76. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  77. }
  78. cell.titleLab.text = [_oneDetail[indexPath.row] allObjects][0];
  79. cell.phoneLab.text = [_oneDetail[indexPath.row] allKeys][0];
  80. cell.detailTextLabel.textColor = RQMianColor;
  81. return cell;
  82. }
  83. -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  84. if (indexPath.row == 0) {
  85. return;
  86. }
  87. NSMutableString* str=[[NSMutableString alloc] initWithFormat:@"telprompt://%@",[_oneDetail[indexPath.row] allKeys][0]];
  88. if ([[[UIDevice currentDevice] systemVersion] floatValue] > 10) {
  89. [[UIApplication sharedApplication] openURL:[NSURL URLWithString:str] options:@{} completionHandler:nil];
  90. }else{
  91. [[UIApplication sharedApplication] openURL:[NSURL URLWithString:str]];
  92. }
  93. }
  94. /*
  95. #pragma mark - Navigation
  96. // In a storyboard-based application, you will often want to do a little preparation before navigation
  97. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  98. // Get the new view controller using [segue destinationViewController].
  99. // Pass the selected object to the new view controller.
  100. }
  101. */
  102. @end