完成按鈕我的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