jverdi/JVFloatLabeledTextField — pull request #45 by ArtSabintsev (2014-02-06 09:06:45+00:00)
Title: Added ability to disable pasting to JVFloatLabeledTextField

There certain situations where I, and others, may want to disallow pasting in a textfield. For instance, if I want the last 4 digits of someone's SSN, or their phone number, I only want to allow numbers in the text field. There are three ways of enforcing this condition:

- Using `UIKeyboardTypeNumberPad`. Another way, is by monitoring every character that gets entered
- Using `- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string`. This second option an ugly way of doing it.
- Front-end validation that checks for non-numerics in the text field.

However, the first two options can be circumvented by allowing data from a different field to be pasted into this field. The third option is just annoying. A cleaner, more elegant manner of implementing this feature is to disallow pasting into the textfield. This can be achieved using the `canPerformAction:withSender` UIResponder method. However, this method must be implemented inside a subclassed UITextField. I have done just that within JVFloatLabeledTextField .h/.m.

As I use Cocoapods to manage your repo, and I'm not wanting to subclass JVFloatLabeledTextField directly within my project (e.g., lazy), I decided to create this change and submit it to you for your evaluation.

Hopefully, I've presented my case, and that you'll consider adding this change.

Thanks for your consideration!