Hide UIPickerview On Finish Button in UITableView

I have a UITextField in each UITableview cell and I added the UIPickerview as inputView UITextField and show the Done button on the toolbar

My question is, how can I hide this popup (Picker + toolbar) when I click Finish? and display the selected collector value in a text box in a specific cell?

Thanks and Regards

Edit: Code

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; PremiumProductsDescriptionCell *cell = (PremiumProductsDescriptionCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[PremiumProductsDescriptionCell alloc] initShoppingCartCellWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease]; } ShopProduct *p = (ShopProduct *)[[ShopProduct GetShoppingCart] objectAtIndex:indexPath.row]; cell.Quantity.text = [NSString stringWithFormat:@"%d",p.Quantity]; UIPickerView *quantityPicker = [[UIPickerView alloc] init]; quantityPicker.dataSource = self; quantityPicker.delegate = self; UIToolbar *myToolbar = [[UIToolbar alloc] initWithFrame: CGRectMake(0,0, 320, 44)]; UIBarButtonItem *doneButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(hideKeyBoard)]; quantityPicker.tag = indexPath.row; [myToolbar setItems:[NSArray arrayWithObject: doneButton] animated:NO]; cell.Quantity.inputAccessoryView = myToolbar; cell.Quantity.inputView = quantityPicker; cell.Quantity.delegate = self; return cell; } 

Solved: I used currentTextBox for the variable and added the following method and resized my first responder with a click of a button :)

 - (void)textFieldDidBeginEditing:(UITextField *)textField { currentTextBox = textField; } 
+1
source share
3 answers

UIPopOver cannot be fired from its class, and you need to fire it from the calling class. You must call the reject method from the popover class when the user clicks the done button

 -(void)doneButtonClikd { ParentClass *viewController=[ParentClass alloc]init]; [viewController dismissPopOver]; } 

I think this will solve your problem. For your input -

  -(void)doneButtonclikd { [selectedTextfield resignFirstResponder]; } 

Remember to save the currently selected text box.

+1
source

Assuming you put a UIPickerView in a popover, here's how to do it:

  UIPopoverController* popover = .... UIBarButtonItem* doneButton = .... [doneButton addTarget:self action:@selector(closeMe) forControlEvents:UIControlEventTouchUpInside] // .... - (void)closeMe { // Assuming popover is really a field or something... [popover dismissPopoverAnimated:YES]; } 
0
source

Use the [self.view endEditing: YES] method.

0
source

All Articles