Search code examples
iphoneiosipadcore-text

iOS 6: Turn off keyboard shortcuts


Is there is any way to turn off keyboard shortcuts in iOS 6 for particular textfield/textview? I want to turn off keyboard shortcut for my app only and not from 'Settings app' of iOS.

I started writing my own text editor to achieve it.


Solution

  • There is no standard way to turn off keyboard shortcuts on application level (For non jailbroken iOS). To achieve this I stated with implementation of custom TextView with Core Text and UITextInput protocol. Add @property for keyBoardShortCuts, Override "tokenizer" getter method by following way to turn off shortcuts.

    - (id <UITextInputTokenizer>)tokenizer {
        if(self.keyBoardShortCuts)
            return _tokenizer;
        else
            return nil;
    }
    

    If we remove tokenizer, there is be no keyboard shortcuts in custom view, even though shortcut are turned on from iOS setting.

    Note: Take care of one thing, as we are not depending on tokenizer, now, in this case, use enumerateSubstringsInRange:range options:NSStringEnumerationByWords/Lines block to find out selection range for word or line.

    To try this add above code in EGOTextView project to turn off default shortcuts.