以前のViewコントローラでは、複数の処方箋タイトルが表示されています。特定のセルをクリックした後、それは次のようにサーバに次のビューに行くと呼ん:menu_itemsでなぜtableviewに辞書の配列が表示されないのですか?
::
::
[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_itemes: (
{
bp = "000/000";
dateTime = "05/12/2016 01:02:59 PM";
doc = {
"email_id" = "[email protected]";
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" = "[email protected]";
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;
}
しかし、何も表示されません。私はnumberOfRowsInSection
が、その後、呼ばcellForRow
1で与えるとき
iは
NSLog(@"content = %@",content);
でnull
だ...と私はその後、menuItems.count
を書くときcellForRow
は呼ばれないでしょう。
私は間違っています。
誰でも私の問題を解決することができます。助けが相当になるでしょう。
この行にブレークポイントを設定します。NSLog(@ "content =%@"、content); '配列が空でないかどうかを確認します。 –
if(ResponseArray.count> 0) { self.menuItems = [[NSMutableArray alloc] initWithArray:ResponseArray]; } NSLog(@ "menu_itemes:%@"、_ menuItems);これで、私は正しい答えを得ました。 –
OKですが、再度cellForRowAtIndexPathで配列を確認してください:もう一度。 –