开发者

How to create custom uitableview like that

开发者 https://www.devze.com 2023-03-10 03:58 出处:网络
I want to create ui开发者_如何学JAVAtableview like the following , also I need to add a third section that contains rows

I want to create ui开发者_如何学JAVAtableview like the following , also I need to add a third section that contains rows

How to create custom uitableview like that

any suggestion please


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;

}



You can take UITableview with style "Group" and can have 3 sections.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号