SaiJob's
SaiJob's

Reputation: 51

How we can pass the DatePicker values into UITableView in UITextField?

I have three text fields. The three fields are taken in UITableViewCell, this cell is passed into UITableViewController. In this tableviewcontroller I have taken date-picker for each custom cell textfield. It's showing date pickers.

My problem is, while changing the picker value is does not place on text..the value is showing in consoles but it's not showing in table view text field...

Upvotes: 1

Views: 1597

Answers (4)

Sanket Pandya
Sanket Pandya

Reputation: 1095

try working out this

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

}

Upvotes: 0

Narayana Rao Routhu
Narayana Rao Routhu

Reputation: 6323

table reload is procedure and another is like below

in .h file take one textField object like

    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"
    }

Upvotes: 0

Hanuman
Hanuman

Reputation: 642

Just check you have the right things in place

    - (void)datePickerValueChanged:(UIDatePicker*)datePicker
    {
       NSIndexPath *indexPath = selectedIndexPath;

           [tableData replaceObjectAtIndex:indexPath.row withObject:datePicker.date];

           [self.tableView reloadData];
    }

let me know more in detail your issue

Upvotes: 1

Antonio MG
Antonio MG

Reputation: 20410

Have you tried reloading your table view after chaging some value?

[myTableview reloadData];

Upvotes: 0

Related Questions