I have a textbox in which I wanted a user to enter only numbers. I have implemented the number keypad there. But if someone puts my app in the background and copies some character string from some other app and comes back to my app and pastes it, it successfully pastes the string content into my numeric textfield. How can I restrict this scenario?
Share
@theChrisKent is close, but there’s a slightly better way. Use the delegate method
-textView:shouldChangeTextInRange:replacementText:. Check ifreplacementTextcontains any non-numbers, and if so returnNO.