你好我是iOS的初学者我已经创建了自定义表格视图并且我有两个数组然后我想在表格视图中同时将两个数组数据一起设置为一个单元格内容我显示我想要的图像..
请参考:http: //i.stack.imgur.com/WIkaf.png
NSMutableArray *SearchPatientCode;
NSMutableArray *SearchPatientName;
UITableView *table_SearchPatient;
SearchPatientCode=[[NSMutableArray alloc]initWithObjects:@"PH230130420",@"PH230420321",@"Ph450362120", nil];
SearchPatientName=[[NSMutableArray alloc]initWithObjects:@"Rahul Sharma",@"Amit kumar",@"anil sharma", nil];
table_SearchPatient=[[UITableView alloc]initWithFrame:CGRectMake(130,40,170,250)style:UITableViewStylePlain];
table_SearchPatient.delegate=self;
table_SearchPatient.dataSource=self;
table_SearchPatient.layer.borderWidth = 2.0;
table_SearchPatient.layer.borderColor = [UIColor grayColor].CGColor;
[self.view addSubview:table_SearchPatient];
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath: (NSIndexPath *)indexPath
{
static NSString *MyIdentifier = @"MyIdentifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier];
if(tableView==table_SearchPatient)
{
if (cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:MyIdentifier] ;
}
cell.textLabel.text =[NSString stringWithFormat:@"%@ /n %@",[SearchPatientCode objectAtIndex:indexPath.row],[SearchPatientName objectAtIndex:indexPath.row]];
cell.textLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:10.0f];
// cell.detailTextLabel.text=[SearchPatientName objectAtIndex:indexPath.row];
}
return cell;
}
我正在使用这个但这不是我想要的显示...解决这个问题!