Reputation: 6451
I want to create uitableview like the following , also I need to add a third section that contains rows
any suggestion please
Upvotes: 1
Views: 624
Reputation: 12325
Do all of this in an UITableViewController with -
UITableViewDelegate, UIPickerViewDelegate, UITableViewDataSource, UIPickerViewDataSource -
For Patient & ACC => Set a UITextField as a Subview (Do this in the cellForRowAtIndexPath for their respective rows)
For Birth and Date => Use the UIDatePickerView and for row ==2 and row ==4 respectively.
For Modality => I do not know what you mean by that; But you need to do something similar
For getting another section for the other two values; Return Section = 2 in
(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
and set title for those accordingly (if needed)
Code :
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier] autorelease];
UITextField *textField = [[UITextField alloc]initWithFrame:CGRectMake(110, 10, 185, 30)];
textField.clearsOnBeginEditing = YES;
textField.textAlignment = UITextAlignmentRight;
textField.returnKeyType = UIReturnKeyDone;
textField.delegate = self;
[cell.contentView addSubview:textField];
if (indexPath.row == 2)
{
UIDatePicker *datePicker = [[UIDatePicker alloc] init];
datePicker.datePickerMode = UIDatePickerModeDate;
[datePicker addTarget:self action:@selector(datePickerValueChangedd:) forControlEvents:UIControlEventValueChanged];
datePicker.tag = indexPath.row;
textField.inputView = datePicker;
NSDateFormatter *df = [[NSDateFormatter alloc] init];
df.dateStyle = NSDateFormatterMediumStyle;
NSString *local;
local = [self datePickerValueChangedd: datePicker];
NSLog(@"%@", local);
textField.text =local;
[datePicker reloadInputViews];
[datePicker release];
}
}
// Configure the cell...
NSInteger row = [indexPath row];
cell.textLabel.text = [doseInfoDetailsArray objectAtIndex:row];
return cell;
}
Upvotes: 1
Reputation: 1631
You can take UITableview with style "Group" and can have 3 sections.
Upvotes: 0