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; }
Hardik kothari
source share