How do I prevent the editing of text in a UITextField along with hiding the cursor/caret/magnifying glass, but still present the keyboard, as I am using an in
To have a UITextField without interaction, but still work with an inputView:
Subclass UITextField with these methods:
// Hide the cursor
- (CGRect)caretRectForPosition:(UITextPosition*)position
{
return CGRectZero;
}
// All touches inside will be ignored
// and intercepted by the superview
- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event
{
return NO;
}
The last method will single-handedly prevent any editing and the magnifier glass, as you won't be able to tap the UITextField.
This works great if you're using a textfield in a UITableViewCell for example, and then can toggle firstResponder status through tableView:didSelectRowAtIndexPath:.