Return Inputs to UITextfield with custom inputView

前端 未结 2 1885
情书的邮戳
情书的邮戳 2021-01-16 17:33

i created a UITextField and a custom View. after that i added this custom view as \"inputView\" to my UITextField.

 amountKeyboardViewController *amountKeybo         


        
2条回答
  •  梦谈多话
    2021-01-16 17:46

    in your amountTextField controller you need to write the following code in .h file

    create property of your textfield

    @property(nonatomic,retain)UiTextField *txt; //whatever your textfield name
    

    Now in .m file write the following

    @synthesize txt;
    

    write following statement where you create object of amountKeyboardViewController

     amountKeyboardViewController *amountKeyboard = [[amountKeyboardViewController alloc] initWithNibName:@"amountKeyboardViewController" bundle:nil]
     amountKeyboard.objamountTextField = self;
    

    Now in amountKeyboardViewController controller write the following code

    @class amountTextField;       //forward declaration
    

    then create object of this class

    amountTextField *objamountTextField;
    

    then create property of

    @property(nonatomic,retain)amountTextField *objamountTextField;
    

    Now on click of button

    -(IBAction)clickof1
    {
        if([amountTextField.text length] <= 0)
            objamountTextField.txt.text = @"1";
        else
            objamountTextField.txt.text=[objamountTextField.txt.text stringByAppendingString:@"1"];
    }
    

提交回复
热议问题