在之前的View控制器中,我显示了多个处方标题。单击特定单元格后,它将转到下一个视图并调用服务器,如下所示:
::
::
[manager POST:Loginurl parameters:params progress:nil success:^(NSURLSessionTask *task, id responseObject) {
NSLog(@"Response from view Prescription server : %@", [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding]);
NSArray *ResponseArray = [NSJSONSerialization JSONObjectWithData: responseObject options: kNilOptions error: nil];
if (ResponseArray.count >0)
{
self.menuItems = [[NSMutableArray alloc]initWithArray:ResponseArray];
}
NSLog(@"menu_itemes: %@",_menuItems);
我在menu_items中获得了以下响应:
menu_itemes: (
{
bp = "000/000";
dateTime = "05/12/2016 01:02:59 PM";
doc = {
"email_id" = "batra@gmail.com";
exception = 0;
gender = Male;
id = 0;
"mobile_no" = 8055621745;
name = Batra;
"profile_id" = 0;
qualification = "MD(Doctor)";
"reg_id" = 157;
salutation = Mr;
"wellness_id" = 251215782521;
};
"follow_up" = 17;
id = 37;
medicine = (
"Syrup,Decold Total,20,0-0-1,Before Meal,1",
"Injection,Insulin,1,0-0-1,Before Meal,1",
no,
no,
no,
no,
no,
no,
no,
no
);
patient = {
"email_id" = "bishtrohit1989@gmail.com";
exception = 0;
gender = Male;
id = 0;
"mobile_no" = 8055621745;
name = Rohit;
"profile_id" = 0;
qualification = "";
"reg_id" = 150;
salutation = Mr;
"wellness_id" = 290119935030;
};
weight = 000;
}
)
我想显示如下数据:
为此,我尝试了以下内容:
我已在屏幕上显示UITableView
。
我为此拍摄了1个静态自定义单元格。
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 1;
// return self.menuItems.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSDictionary *content = [self.menuItems objectAtIndex:0];
NSLog(@"content = %@",content);
ViewPrescriptionTableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:@"PatientDetail" forIndexPath:indexPath];
[cell.datetime setText:[content valueForKey:@"dateTime"]];
[cell.doctorname setText:[[content objectForKey:@"doc"]valueForKey:@"name"]];
return cell;
}
但它没有显示任何内容。
我在
获得了null
NSLog(@"content = %@",content);
当我给numberOfRowsInSection
为1,然后cellForRow
被叫...当我写menuItems.count
时,cellForRow
将不会被调用。
我没错,我错了。
请任何人都可以解决我的问题。帮助将是可观的。
答案 0 :(得分:0)
看起来self.menuItems
正在某处重置为nil。您可以为menuItems
编写一个setter方法,并在setter方法中保留断点以检查哪一段代码正在修改。