// // ContactDetailVC.m // 通讯录 // // Created by EchoShacolee on 2017/5/22. // Copyright © 2017年 lee. All rights reserved. // #import "ContactDetailVC.h" #import "ContactTableViewCell.h" @interface ContactDetailVC () @end @implementation ContactDetailVC - (void)viewDidLoad { [super viewDidLoad]; [self myInit]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } -(void)myInit{ [self goBackByNavigation]; UITableView * tableview = [[UITableView alloc]initWithFrame:kFrame style:UITableViewStylePlain]; tableview.delegate = self; tableview.dataSource = self; tableview.showsVerticalScrollIndicator = NO; tableview.tableFooterView = [UIView new]; [self.view addSubview:tableview]; } #pragma mark tableview代理相关 -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ return [_oneDetail count]; } -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ if (indexPath.row == 0) { return 150; } return 50; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ if (indexPath.row == 0) { UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"xx"]; if (!cell) { cell = [[UITableViewCell alloc]initWithStyle:0 reuseIdentifier:@"xx"]; } cell.selectionStyle = UITableViewCellSelectionStyleNone; CGFloat x,y,w,h; w = h = 80; x = (kSize.width-w)/2; y = 10; UILabel * topLab = [[UILabel alloc]initWithFrame:CGRectMake(x, y, w, h)]; topLab.text = [self.oneDetail[0] substringToIndex:1]; topLab.textAlignment = NSTextAlignmentCenter; topLab.backgroundColor = [UIColor lightGrayColor]; topLab.textColor = [UIColor whiteColor]; topLab.layer.cornerRadius = w/2; topLab.layer.masksToBounds = YES; topLab.font = [UIFont systemFontOfSize:45]; [cell.contentView addSubview:topLab]; x = 0; y += h+10; w = kSize.width; h = 50; UILabel * titleLab = [[UILabel alloc]initWithFrame:CGRectMake(x, y, w, h)]; titleLab.text = self.oneDetail[0]; titleLab.textAlignment = NSTextAlignmentCenter; titleLab.textColor = [UIColor blackColor]; titleLab.font = [UIFont systemFontOfSize:30];//[UIFont fontWithName:@"Helvetica-Bold" size:30] // cell.contentView.backgroundColor = [cell.contentView addSubview:titleLab]; return cell; } ContactTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cellID"]; if (!cell) { cell = [[[NSBundle mainBundle] loadNibNamed:@"ContactTableViewCell" owner:nil options:nil]lastObject]; cell.selectionStyle = UITableViewCellSelectionStyleNone; } cell.titleLab.text = [_oneDetail[indexPath.row] allObjects][0]; cell.phoneLab.text = [_oneDetail[indexPath.row] allKeys][0]; cell.detailTextLabel.textColor = RQMianColor; return cell; } -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ if (indexPath.row == 0) { return; } NSMutableString* str=[[NSMutableString alloc] initWithFormat:@"telprompt://%@",[_oneDetail[indexPath.row] allKeys][0]]; if ([[[UIDevice currentDevice] systemVersion] floatValue] > 10) { [[UIApplication sharedApplication] openURL:[NSURL URLWithString:str] options:@{} completionHandler:nil]; }else{ [[UIApplication sharedApplication] openURL:[NSURL URLWithString:str]]; } } /* #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