у меня 2 UITableView
в UIView
, при перезагрузке данных второй UITableView
.
Я установил, например, количество строк в 345.
cellForRowAtIndexPath
вызывается только 10 раз при вызове функции reloadData
Примечание: отображаемое количество строк во время разработки равно 10.
Как мы можем преодолеть такую проблему?
if( tableView == self.SearchResult)
{
if (QueryClass )
{
NSLog(@"%d",[QueryClass->StudyResults count]); // 500 row
return [QueryClass->StudyResults count];
}
else {
return 0 ;
}
//return [SearchResult_study count ] ;
//return 0 ;
}
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
NSLog(@"BEFORE ENTERING %d",indexPath.row);
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
if(tableView == self.Settings )
{
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier] autorelease];
if (indexPath.row == 0 && indexPath.section == 0 ){
UILabel *PatientLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, 120, 25)];
PatientLabel.backgroundColor = [UIColor clearColor];
PatientLabel.tag = 1;
PatientLabel.text = @"Selected Node " ;
[cell.contentView addSubview:PatientLabel];
SelectedNode = [[UILabel alloc]initWithFrame:CGRectMake(140, 10, 400, 30)];
SelectedNode.backgroundColor = [UIColor clearColor];
SelectedNode.tag = 24 ;
SelectedNode.text = @" Select Node " ;
[cell.contentView addSubview:SelectedNode];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator ;
}
if (indexPath.row == 0 && indexPath.section == 1 ) {
//cell.textLabel.text = "Patient Name";
UILabel *PatientLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, 120, 25)];
PatientLabel.backgroundColor = [UIColor clearColor];
PatientLabel.tag = 1;
PatientLabel.text = @"Study Date" ;
[cell.contentView addSubview:PatientLabel];
StudyDate = [[UILabel alloc] initWithFrame:CGRectMake(140, 10, 400, 30)];
StudyDate.backgroundColor = [UIColor clearColor];
StudyDate.tag = 1;
StudyDate.text = @"Select Date" ;
[cell.contentView addSubview:StudyDate];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator ;
}
if (indexPath.row == 1 && indexPath.section == 1 ) {
//cell.textLabel.text = "Patient Name";
UILabel *PatientLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, 120, 25)];
PatientLabel.backgroundColor = [UIColor clearColor];
PatientLabel.tag = 1;
PatientLabel.text = @"Patient Name" ;
[cell.contentView addSubview:PatientLabel];
PtienttextField = [[UITextField alloc]initWithFrame:CGRectMake(140, 10, 400, 30)];
PtienttextField.textAlignment = UITextAlignmentRight;
PtienttextField.returnKeyType = UIReturnKeyDone;
PtienttextField.delegate = self;
PtienttextField.tag = 21 ;
[PtienttextField setBorderStyle:UITextBorderStyleBezel];
[PtienttextField resignFirstResponder];
[cell.contentView addSubview:PtienttextField];
}
if (indexPath.row == 2 && indexPath.section == 1 ) {
//cell.textLabel.text = "Patient Name";
UILabel *PatientLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, 120, 25)];
PatientLabel.backgroundColor = [UIColor clearColor];
PatientLabel.tag = 1;
PatientLabel.text = @"Acc No" ;
[cell.contentView addSubview:PatientLabel];
ACCNOtextField = [[UITextField alloc]initWithFrame:CGRectMake(140, 10, 400, 30)];
ACCNOtextField.textAlignment = UITextAlignmentRight;
ACCNOtextField.returnKeyType = UIReturnKeyDone;
ACCNOtextField.delegate = self;
ACCNOtextField.tag = 22 ;
[ACCNOtextField setBorderStyle:UITextBorderStyleBezel];
[ACCNOtextField resignFirstResponder];
[cell.contentView addSubview:ACCNOtextField];
}
if (indexPath.row == 3 && indexPath.section == 1 ) {
//cell.textLabel.text = "Patient Name";
UILabel *PatientLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, 120, 25)];
PatientLabel.backgroundColor = [UIColor clearColor];
PatientLabel.tag = 1;
PatientLabel.text = @"Modality " ;
[cell.contentView addSubview:PatientLabel];
ModalityLabel = [[UILabel alloc]initWithFrame:CGRectMake(140, 10, 400, 30)];
ModalityLabel.backgroundColor = [UIColor clearColor];
ModalityLabel.tag = 23 ;
ModalityLabel.text = @" Select Modality " ;
[cell.contentView addSubview:ModalityLabel];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator ;
}
if (indexPath.row == 4 && indexPath.section == 1 ) {
//cell.textLabel.text = "Patient Name";
UILabel *PatientLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, 120, 25)];
PatientLabel.backgroundColor = [UIColor clearColor];
PatientLabel.tag = 1;
PatientLabel.text = @"Birth Date " ;
[cell.contentView addSubview:PatientLabel];
DateOfBirth = [[UILabel alloc]initWithFrame:CGRectMake(140, 10, 400, 30)];
DateOfBirth.backgroundColor = [UIColor clearColor];
DateOfBirth.tag = 24 ;
DateOfBirth.text = @" Select Date " ;
[cell.contentView addSubview:DateOfBirth];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator ;
}
if (indexPath.row == 5 && indexPath.section == 1 ) {
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button addTarget:self action:@selector(Search:)
forControlEvents:UIControlEventTouchDown];
[button setTitle:@"Search" forState:UIControlStateNormal];
button.frame = CGRectMake(140, 10, 400, 30);
[cell.contentView addSubview: button ] ;
}
}
if( tableView == self.SearchResult)
{
NSLog(@"ENTERED SEARCH RESULT %d",indexPath.row) ;
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
FindResultsClass *data = [[FindResultsClass alloc] init];
// repeat just the first 10 values
data = [QueryClass->StudyResults objectAtIndex: indexPath.row];
cell.textLabel.text = data.patientName;
/*if (data.StudyDate)
{
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:@"dd/MM/YYYY"];
NSDate *date = [dateFormat dateFromString:data.StudyDate];
cell.detailTextLabel.text = [dateFormat stringFromDate:date];
[dateFormat release];
}*/
}
}
// Configure the cell.
return cell;
}