条件とユーザー入力の回答を持つカスタムUITableViewCellがあるアプリを作成しています。ユーザーの便宜のために、選択した行に応じてキーボードの種類を変更したいと思います。
例えば。「Cost」行には、ユーザーが入力できるテンキーキーボードが表示され、「Suburb」行には、ユーザーが入力できる標準キーボードが表示されます。
これが皆さんを助けるための画像です。このセルには、標準のキーボードが必要です。
条件とユーザー入力の回答を持つカスタムUITableViewCellがあるアプリを作成しています。ユーザーの便宜のために、選択した行に応じてキーボードの種類を変更したいと思います。
例えば。「Cost」行には、ユーザーが入力できるテンキーキーボードが表示され、「Suburb」行には、ユーザーが入力できる標準キーボードが表示されます。
これが皆さんを助けるための画像です。このセルには、標準のキーボードが必要です。
とても簡単です。あなたはこのようにあなたを修正することができます-cellForRowAtIndexPath:
:
if (indexPath.row == 1)
{
[textField setKeyboardType:UIKeyboardTypeNumberPad];
}
else if ()
{
}..
いくつかのキーボードタイプは次のとおりです。
UIKeyboardTypeDefault, // Default type for the current input method.
UIKeyboardTypeASCIICapable, // Displays a keyboard which can enter ASCII characters, non-ASCII keyboards remain active
UIKeyboardTypeNumbersAndPunctuation, // Numbers and assorted punctuation.
UIKeyboardTypeURL, // A type optimized for URL entry (shows . / .com prominently).
UIKeyboardTypeNumberPad, // A number pad (0-9). Suitable for PIN entry.
UIKeyboardTypePhonePad, // A phone pad (1-9, *, 0, #, with letters under the numbers).
UIKeyboardTypeNamePhonePad, // A type optimized for entering a person's name or phone number.
UIKeyboardTypeEmailAddress, // A type optimized for multiple email address entry (shows space @ . prominently).
データを入力するためにカスタムセルにテキストフィールドを配置している場合、
if (indexPath.row == 1)
{
textfield.keyboardType = UIKeyboardTypeNumberPad; //(for number keypad)
}
さまざまなキーボードの種類があります。
標準キーボードの場合、列挙型を使用しますUIKeyboardTypeDefault
-cellForRowAtIndexPath:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:
(NSIndexPath *)indexPath
{
UITableViewCell *cell = nil;
static NSString *CellIdentifier = @"cellidentifier";
CustomCell *tableCustomCell = (CustomCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (tableCustomCell == nil)
{
[[NSBundle mainBundle]loadNibNamed:@"CustomCell" owner:self options:nil];
tableCustomCell = self.customCell;
self.customCell = nil;
}
//Here add the check for the textfields
cell = tableCustomCell;
return cell;
}
これがあなたを助けることを願っています。