NSDictionary
:
(
{
bp = "158/56";
dateTime = "05/12/2016 11:51:12 AM";
doc = {
"email_id" = "gkalal64@gmail.com";
exception = 0;
gender = Male;
id = 0;
"mobile_no" = 8149910113;
name = Kabadia;
"profile_id" = 0;
qualification = MBBS;
"reg_id" = 100;
salutation = Mr;
"wellness_id" = IN8S2D29A2;
};
"follow_up" = 14;
id = 6;
medicine = (
"Injection,Crocin,5,0-1-0,After Meal,2",
"Powder,churan,10,1-0-0,Before Meal,14",
no,
no,
no,
no,
no,
no,
no,
no
);
patient = {
"email_id" = "bishtrohit1989@gmail.com";
exception = 0;
gender = Male;
id = 0;
"mobile_no" = 8624088776;
name = kamlesh;
"profile_id" = 0;
qualification = "";
"reg_id" = 101;
salutation = Mr;
"wellness_id" = IND16HRR65;
};
weight = 47;
}
)
我想按以下方式显示以上信息:
但我不知道该怎么做。我搜索了这个,但我没有确切地知道如何做到这一点。
我做了什么:
在之前的View控制器中,我显示了多个处方标题。点击特定的单元格后,我调用了这个视图,我得到了服务器的上述响应,我希望显示如上图像。
我已在屏幕上显示UITableView
。
我为此拍摄了1个静态自定义单元格。
但我不知道该怎么做。
请任何人都可以解决我的问题。帮助将是可观的。
答案 0 :(得分:2)
更新了答案
if (indexPath.row < responseArray.count){
NSString *docName = @"";
NSString *contact = @"";
NSString *wellness_id = @"";
if ([selectedDict valueForKey:@"doc"] != nil){
NSDictionary *doctorDict = [selectedDict valueForKey:@"doc"];
NSString *lDocName = [doctorDict valueForKey:@"name"];
if(lDocName.length > 0){
docName = lDocName;
}
NSString *qulification = [doctorDict valueForKey:@"qualification"];
if(qulification.length > 0){
docName = [NSString stringWithFormat:@"%@ %@", docName, qulification];
}
NSString *mobile_no = [doctorDict valueForKey:@"mobile_no"];
if(mobile_no.length > 0){
contact = mobile_no;
}
NSString *email_id = [doctorDict valueForKey:@"email_id"];
if(email_id.length > 0){
contact = [NSString stringWithFormat:@"%@ / %@", contact, email_id];
}
NSString *wellness_idTemp = [doctorDict valueForKey:@"wellness_id"];
if(wellness_idTemp.length > 0){
wellness_id= [NSString stringWithFormat:@"Wellness_Id : %@", wellness_idTemp];
}
}
cell.docNameLabel.text = docName;
cell.contact.text = contact;
cell.wellnessID.text = wellness_id;
NSString *patientName = @"";
NSString *patientcontact = @"";
NSString *patientWellness_id = @"";
NSString *bloodPressure = [selectedDict valueForKey:@"bp"];
NSString *weight = [selectedDict valueForKey:@"weight"];
if ([selectedDict valueForKey:@"patient"] != nil){
NSDictionary *patientDict = [selectedDict valueForKey:@"patient"];
NSString *lName = [patientDict valueForKey:@"name"];
if(lName.length > 0){
patientName = lName;
}
NSString *mobile_no = [patientDict valueForKey:@"mobile_no"];
if(mobile_no.length > 0){
patientcontact = mobile_no;
}
NSString *email_id = [patientDict valueForKey:@"email_id"];
if(email_id.length > 0){
patientcontact = [NSString stringWithFormat:@"%@ / %@", contact, email_id];
}
NSString *wellness_idTemp = [patientDict valueForKey:@"wellness_id"];
if(wellness_idTemp.length > 0){
patientWellness_id = [NSString stringWithFormat:@"Wellness Id : %@", wellness_idTemp];
}
}
cell.patientNameLabel.text = patientName;
cell.contact.text = patientcontact;
cell.wellnessID.text = wellness_id;
cell.bp.text = bloodPressure;
cell.weight.text = weight;
}
希望这会有所帮助。
答案 1 :(得分:2)
根据您的数据结构,我猜您的数据是一种单一对象,因此很明显它不是同一类对象的集合(数组),所以我建议您只为这整个单个记录创建一个自定义单元格。
在这种情况下,您的TableView
只有一行。
在自定义单元格中:让我们称之为'PatientDetail'
如何运作?
正如您所说的特定列表的详细信息屏幕所以我们将在tableview中显示其中包含所有详细信息的单行。
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 1;
}
以下代码
responseDict
NSDictionary
这是第一个响应对象,因为您的响应是一种数组。
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
PatientDetail *cell=[tableView dequeueReusableCellWithIdentifier:@"PatientDetail" forIndexPath:indexPath];
//Setting
[cell.lbDateTime setText:[responseDict valueForKey:@"dateTime"]];
//Doctor name Just
[cell.lbDoctorName setText:[[responseDict objectForKey:@"doc"]valueForKey:@"name"]];
//Follow the above steps for all the details
return cell;
}