0

条件とユーザー入力の回答を持つカスタムUITableViewCellがあるアプリを作成しています。ユーザーの便宜のために、選択した行に応じてキーボードの種類を変更したいと思います。

例えば。「Cost」行には、ユーザーが入力できるテンキーキーボードが表示され、「Suburb」行には、ユーザーが入力できる標準キーボードが表示されます。

これが皆さんを助けるための画像です。このセルには、標準のキーボードが必要です。

http://i.stack.imgur.com/rGFhC.png

4

2 に答える 2

0

とても簡単です。あなたはこのようにあなたを修正することができます-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).
于 2013-01-14T10:17:35.393 に答える
0

データを入力するためにカスタムセルにテキストフィールドを配置している場合、

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;

}

これがあなたを助けることを願っています。

于 2013-01-14T11:31:36.103 に答える