- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { // 为其定义一个标识符,在重用机制中,标识符非常重要,这是系统用来匹配table各行cell的判断标准,在以后的学习中会体会到 static NSString *identifier = @"identifier"; // 从缓存队列中取出复用的cell(重用队列中取出cell) UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];#pragma mark -- 自定义cell UILabel *carriers; //运营商 UILabel *telPhone; //电话号码 UILabel *time; //通话时间 UILabel *date; //通话日期 // 如果队列中cell为空,即无复用的cell,则对其进行初始化 if (cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:identifier]; // 定义其辅助样式 cell.accessoryType = UITableViewCellAccessoryDetailButton; //运营商 CGRect carriersF = CGRectMake(30, 30, 80, 30); carriers = [[UILabel alloc] initWithFrame:carriersF]; carriers.font = [UIFont systemFontOfSize:12]; [cell addSubview:carriers]; //电话号码 CGRect telPhoneF = CGRectMake(30, 8, 80, 30); telPhone = [[UILabel alloc] initWithFrame:telPhoneF]; telPhone.font = [UIFont systemFontOfSize:16]; [cell addSubview:telPhone]; //通话时间 CGRect timeF = CGRectMake(270, 8, 80, 30); time = [[UILabel alloc] initWithFrame:timeF]; time.font = [UIFont systemFontOfSize:16]; [cell addSubview:time]; //通话日期 CGRect dateF = CGRectMake(270, 30, 80, 30); date = [[UILabel alloc] initWithFrame:dateF]; date.font = [UIFont systemFontOfSize:12]; [cell addSubview:date]; } NSDate * senddate=[NSDate date]; NSDateFormatter *dateformatter=[[NSDateFormatter alloc] init]; [dateformatter setDateFormat:@"YYYY-MM-dd"]; NSString * locationString=[dateformatter stringFromDate:senddate]; NSArray *array = [self.dataSourceArray objectAtIndex:indexPath.row]; carriers.text =@"中国移动"; telPhone.text = array[0]; time.text = array[1]; date.text = locationString; return cell;}