相关疑难解决方法(0)

UITextField中的UIDatePicker在UITableView实时更新中

这个问题最近一直困扰着我.任何帮助,将不胜感激.

这些是我的目标:

  1. 在UITableViewCell中为UItextField设置UIDatePickerView.

到目前为止,我已经完成了所有这些,我可以看到选择器工作正常.每当我更改选择器值时,我都会使用NSLog来显示当前值,并且每次更改都能正常工作.

这就是我想要的东西: **每当我改变pickervalue,我需要的价值,也可以在的UITextField(这是在UITableViewCell中)自动改变**

这是我的CellForRowIndexPath代码:

- (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;

    [cell.contentView addSubview:textField];
     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; …
Run Code Online (Sandbox Code Playgroud)

iphone xcode objective-c uidatepicker uipickerview

5
推荐指数
1
解决办法
8851
查看次数

标签 统计

iphone ×1

objective-c ×1

uidatepicker ×1

uipickerview ×1

xcode ×1