Bir eksi olarak ekleme ekleyinGörüntüleme, metninizin bir Özellik olarak olması gerekir, bu örnekte bu özellik: myTextField;
Bu kodu myTextField oluşturduktan sonra eklemeniz gerekir, b.e.
UIView *inputAccesoryView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 40)];
// It´s good idea a view under the button in order to change the color...more custom option
inputAccesoryView.backgroundColor = [UIColor whiteColor];
UIButton *minusButton = [[UIButton alloc] initWithFrame:CGRectMake(([UIScreen mainScreen].bounds.size.width-150)/2, 5, 150, 30)];
// configure the button here... you choose.
[minusButton setTitle:@"-" forState:UIControlStateNormal];
[minusButton addTarget:self action:@selector(changeNumberSing) forControlEvents:UIControlEventTouchUpInside];
[inputAccesoryView addSubview:minusButton];
self.myTextField.inputAccessoryView = inputAccesoryView;
Ve ViewController bu düğmeye yöntemleri eklemek: viewDidLoad
-(void)changeNumberSing
{
if ([self.myTextField.text hasPrefix:@"-"])
{
self.myTextField.text = [self.myTextField.text substringFromIndex:1];
}else
{
self.myTextField.text = [NSString stringWithFormat:@"-%@",self.myTextField.text];
}
}
, özel klavye – Sport
Diğer seçeneği oluşturmak bir ekleme - Bir bir inputAccessoryView olarak eksi Düğmesi(). Veya mutlu olun: UIKeyboardTypeNumbersAndPunctuation –
@OnikIV Bir inputAccessoryView olarak eksi düğmesi nasıl eklenir? – AndyW