完成按钮我的UITextField在UITableView中的每个Cell,我已经加入UIPickerview作为的UITextField的inputView,并完成按钮显示在其工具栏隐藏UIPickerview论的UITableView
我的问题是我怎么能隐藏此此弹出(Picker +工具栏)点击完成按钮? 并在特定单元格的文本框中显示选取器的选定值?
感谢和问候
编辑:代码
- (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一个变量,并添加下面的方法,并在完成按钮的点击:)
- (void)textFieldDidBeginEditing:(UITextField *)textField
{
currentTextBox = textField;
}
调整它的第一个响应者
感谢,但我不使用UIPopoverController我刚才设置的UITextField – 2012-04-03 07:09:23
的inputView财产请更新您的问题,显示代码为显示uipickerview – 2012-04-03 07:10:55
好吧,我已更新的代码 – 2012-04-03 07:18:25