CustomCell в UITableView в Objective C
Я приложил пример вывода здесь .... Он имеет две ячейки первого из них, имеющие functioncode, StartTime, время окончания и второй имеет время перерыва.
Теперь хочу я хочу сделать, это третий один должен содержать functionCode:, время_запуска:, время окончания :,
Мой массив имеет 3 словаря
(
{
date = "2016-01-20";
"end_time" = "11:10:00";
"function_code" = RCV;
"operator_id" = JOHN;
"start_time" = "11:00:00";
"total_time" = 10;
"total_units" = 19;
},
{
"break_time" = 65;
},
{
date = "2016-01-20";
"end_time" = "12:25:00";
"function_code" = PIK;
"operator_id" = JOHN;
"start_time" = "12:15:00";
"total_time" = 10;
"total_units" = 26;
})
Это мой cellforrow по методу indexpath
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.row ==0)
{
self.tempDictionary = [self.arrData1 objectAtIndex:indexPath.row];
NSLog(@"The dictionary contains:%@",self.tempDictionary);
static NSString *CellIndentifier [email protected]"TableViewCell";
TableViewCell *cell =[tableView dequeueReusableCellWithIdentifier:CellIndentifier];
if (cell == nil) {
cell = [[TableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIndentifier];
}
NSLog(@" the dictionary contains all :%@",self.tempDictionary);
NSString *strFunctionCodeValue =[self.tempDictionary objectForKey:@"function_code"];
NSString *strStartTimeValue = [self.tempDictionary objectForKey:@"start_time"];
NSString *strEndTimeValue = [self.tempDictionary objectForKey:@"end_time"];
NSString *strTotalUnitsValue =[self.tempDictionary objectForKey:@"total_units"];
NSString *strTotalTimeValue = [self.tempDictionary objectForKey:@"total_time"];
cell.lblFunctionCodeValue.text = strFunctionCodeValue;
cell.lblStartTimeValue.text = strStartTimeValue;
cell.lblEndTimeValue.text = strEndTimeValue;
cell.lblTotalUnitsValue.text =strTotalUnitsValue;
cell.lblTotalTimeValue.text = strTotalTimeValue;
return cell;
}
else
{
static NSString *cellIdentifier1 [email protected]"TableViewCell1";
self.tempDictionary = [self.arrData1 objectAtIndex:indexPath.row];
NSLog(@" dicitionary :%@",self.tempDictionary);
TableViewCell1 *cell1 =(TableViewCell1 *)[tableView dequeueReusableCellWithIdentifier:cellIdentifier1];
if (cell1 == nil) {
cell1 =[[TableViewCell1 alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier1];
}
NSString *breakTimeValue = [self.tempDictionary objectForKey:@"break_time"];
cell1.lblBreakTimeValue.text = breakTimeValue;
return cell1;
}
}
Спасибо @shehzad Ali, я получил ошибку, так как управление может дойти до конца не-void функции, –
return nil в конце функции. –
ya я использовал return nil в конце функции, приложение получило сбой. «NSInternalInconsistencyException», причина: «UITableView dataSource должен вернуть ячейку из tableView: cellForRowAtIndexPath:« это ошибка –