How do I use Vmasktextfield with Swift?

Asked

Viewed 1,043 times

1

How do I use Vmasktextfield with Swift?

self.comVM.Mask = "###(##)##"

  • Please serve this answer: http://answall.com/questions/40229/máscara-para-uitextfield/40293#40293

1 answer

2

Example:

class ViewController: UIViewController, UITextFieldDelegate {

    @IBOutlet weak var comVM: VMaskTextField!

    override func viewDidLoad() {
        super.viewDidLoad()

        comVM.mask = "(##) ####-####";
        comVM.delegate = self;
    }

    func textField(textField: UITextField, shouldChangeCharactersInRange range: NSRange, replacementString string: String) -> Bool {
        return comVM.shouldChangeCharactersInRange(range, replacementString: string);
    }
}

Don’t forget to change the class of UITextField for VMaskTextField in storyboard/nib .

  • It didn’t work here. = / is giving this error 2017-08-02 17:18:45.161 iSkyNote[29691:421271] *** Terminating app due to uncaught Exception 'Nsinvalidargumentexception', Ason: '-[Uitextfield setTextWithMask:]: unrecognized selector sent to instance 0x7afb7450'

Browser other questions tagged

You are not signed in. Login or sign up in order to post.