アプリケーションで作成し、価格を入力する必要がありました。クライアントは独自のデザインのキーボードを必要としていたので、次のキーボードを開発しました。それは完璧に動作します。問題は、テキストが より大きく、UITextField
ドットが表示される場合です。私はグーグルとSOで検索しましたが、何も見つかりませんでした。
uitextfield の横のドットを避ける
方法 UITextfield のドットを削除するには? および他の答えですが、私の場合は機能しません。デフォルトのキーボードを使用すると、入力した番号のテキストがスクロールされます
私のキーボードは
長さが TextFied 幅よりも大きい場合は、表示されます
私のコードは
- (IBAction)numberPressed:(id)sender {
UIButton *btn=(UIButton *)sender;
int number=btn.tag;
if (number <= 9)
txtPrice.text = [NSString stringWithFormat:@"%@%d",txtPrice.text, number];
//decimal point
else if (number == 10) {
if ([txtPrice.text rangeOfString:@"."].location == NSNotFound)
txtPrice.text = [NSString stringWithFormat:@"%@.", txtPrice.text];
}
//0
else if (number == 11)
txtPrice.text = [NSString stringWithFormat:@"%@0", txtPrice.text];
//backspace
else if (number == 12) {
if ([txtPrice.text length] > 0)
txtPrice.text = [txtPrice.text substringToIndex:[txtPrice.text length] - 1];
else
txtPrice.text = @"";
}
}
#pragma mark -
#pragma mark -TextField Delegate Method
-(BOOL)textFieldShouldBeginEditing:(UITextField *)textField {
[self showKeyboard];
return NO; // Hide both keyboard and blinking cursor.
}
- (BOOL)textFieldShouldEndEditing:(UITextField *)textField
{
return YES;
}