Iphone 在UITableView中隐藏UIPickerview On Done按钮
我在UITableview的每个单元格中都有UITextField,我将UIPickerview添加为UITextField的inputView,并在其工具栏上显示“完成”按钮 我的问题是如何在单击“完成”按钮时隐藏此弹出窗口(选择器+工具栏)? 并在特定单元格的文本框中显示选择器的选定值 谢谢和问候 编辑:代码Iphone 在UITableView中隐藏UIPickerview On Done按钮,iphone,ios,ipad,Iphone,Ios,Ipad,我在UITableview的每个单元格中都有UITextField,我将UIPickerview添加为UITextField的inputView,并在其工具栏上显示“完成”按钮 我的问题是如何在单击“完成”按钮时隐藏此弹出窗口(选择器+工具栏)? 并在特定单元格的文本框中显示选择器的选定值 谢谢和问候 编辑:代码 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *
- (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;
}
已解决:
我将currentTextBox作为一个变量,添加了以下方法,并在“完成”按钮的单击中调整其第一个响应程序的大小:)
假设您将
UIPickerView
放在一个popover中,下面介绍如何操作:
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];
}
假设您将
UIPickerView
放在一个popover中,下面介绍如何操作:
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];
}
UIPopOver不能从其类中删除,您需要从调用类中删除它。 当用户按下“完成”按钮时,必须从popover调用类中调用Disclose方法
-(void)doneButtonClikd
{ ParentClass *viewController=[ParentClass alloc]init];
[viewController dismissPopOver];
}
我想这会解决你的问题
用于您的inputview-
-(void)doneButtonclikd
{ [selectedTextfield resignFirstResponder];
}
不要忘记保存当前选择的文本字段。UIPover不能从其类中删除,您需要从调用类中删除它。 当用户按下“完成”按钮时,必须从popover调用类中调用Disclose方法
-(void)doneButtonClikd
{ ParentClass *viewController=[ParentClass alloc]init];
[viewController dismissPopOver];
}
我想这会解决你的问题
用于您的inputview-
-(void)doneButtonclikd
{ [selectedTextfield resignFirstResponder];
}
不要忘记保存当前选定的文本字段。使用[self.view endEditing:YES]方法。使用[self.view endEditing:YES]方法。谢谢,但我没有使用UIPopoverController我刚刚设置了UIExtField的inputView属性谢谢,但我没有使用UIPopoverController我刚刚设置了UIExtField的inputView属性谢谢,但我没有使用UIPopoverController我刚刚设置了UIExtField的inputView属性请更新您的问题并显示代码显示UIPickerViewHanks但我没有使用UIPopoverController我刚刚设置了UIExtField的inputView属性请更新您的问题并显示显示uipickerview的代码