我有三个文本字段。这三个字段是在UITableViewCell中获取的,这个单元格被传递到UITableViewController中。在这个tableviewcontroller中,我为每个自定义单元格文本字段选择了日期选择器。它显示了日期选择器。
我的问题是,虽然更改选择器值不会放在文本上...值会显示在控制台中,但它不会显示在表格视图文本字段中...
答案 0 :(得分:1)
检查你是否有正确的东西
- (void)datePickerValueChanged:(UIDatePicker*)datePicker
{
NSIndexPath *indexPath = selectedIndexPath;
[tableData replaceObjectAtIndex:indexPath.row withObject:datePicker.date];
[self.tableView reloadData];
}
让我更详细地了解您的问题
答案 1 :(得分:0)
您是否尝试在更改某个值后重新加载表格视图?
[myTableview reloadData];
答案 2 :(得分:0)
尝试解决这个问题
NSString *datePicValue;
- (void)viewpic:(DatePicker *)viewpic didSelectValue:(NSString *)value
{
datePicValue=[[NSString alloc] initWithString:value];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
WorkOrderObj *obj=[app.bookdJobData objectAtIndex:indexPath.row];
NSLog(@"workObj Count:%d",[app.bookdJobData count]);
static NSString *CustomCellIdentifier = @"ContactLogCC";
ContactLogCC *cell = (ContactLogCC *)[tableView dequeueReusableCellWithIdentifier: CustomCellIdentifier];
if (cell == nil)
{
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"ContactLogCC" owner:self options:nil];
{
for (id oneObject in nib) if ([oneObject isKindOfClass:[ContactLogCC class]])
cell = (ContactLogCC *)oneObject;
}
cell.lblDate.text=datePicValue;
}
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
self.ViewDate = [[[DatePicker alloc]
initWithNibName:@"DatePicker"
bundle:[NSBundle mainBundle]] autorelease];
ViewDate.contentSizeForViewInPopover=CGSizeMake(ViewDate.view.frame.size.width, ViewDate.view.frame.size.height);
ViewDate.delegate = self;
self.popoverController = [[[UIPopoverController alloc] initWithContentViewController:ViewDate] autorelease];
[self.popoverController presentPopoverFromRect:CGRectMake(400,140, ViewDate.view.frame.size.width, ViewDate.view.frame.size.height)
inView:tblVw
permittedArrowDirections:UIPopoverArrowDirectionLeft
animated:YES];
}
答案 3 :(得分:0)
表重新加载是程序,另一个是下面的
<。>在.h文件中使用一个textField对象,如 UITextField *txt_current;
in .m
- (void)textFieldDidBeginEditing:(UITextField *)textField;
{
txt_current = textField;
}
-(void) pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component{
txt_current.text = @"selected value"
}