Force application to use Apple Keyboard in iOS 8

How can I get UITextfields apps to use only Apple keyboard in iOS 8? I do not want to allow third-party keyboards, period. I understand that this may be a bad user experience, so please do not discuss this issue with me :)

I know that I can set the secureEntry property to true to force the Apple keyboard ( http://www.imore.com/custom-keyboards-ios-8-explained ). Maybe iOS 8 will allow me to set this property and DO NOT mask the text?

+7
security ios uitextfield ios8 ios-app-extension
source share
3 answers

By setting the UITextView or UITextField property from Secure Text Entry to YES , custom keyboards will not be displayed by default and cannot be switched either.

It is also, unfortunately, to hide information about a keystroke, as well as drag and drop automatic caps and automatically correct and sketch suggestions. Therefore, you should switch back to NO after you have forced the user to use the Apple keyboard.

Switching this property and then turning it off may cause the Apple Keyboard to become the first key that appears by default.


NOW, the user can still press the global key so that you have two options:

• First, you can simply enable them and determine if they are using [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(inputModeDidChange:) name:@"UITextInputCurrentInputModeDidChangeNotification" object:nil]; and just override the secureTextEntry code above and force switch to the default Apple keyboard (unprofessional method, but very easy to program). (* Note! This will also prevent users from using the dictation keyboard (by clicking the microphone icon button next to the space bar) unless you use undocumented code to determine if it is dictation or not (which exists and presumably passed the Apple Validation on multiple accounts . Information about this can be found here )


Or


• Two: use UIWindows to get the default ONTOP keyboard and add a UIWindow with userInteractionEnabled set to YES covering the location of this key (this will require several conditional statements to make sure that you close the rights) change the keyboard "for every opportunity . (e.g. iPhone4 landscape keyboard, iPhone5 portable keyboard, etc.).

Here is some demo code, although it works for portrait keyboards (iphone5 and iphone4)


:

viewController.h

 #import <UIKit/UIKit.h> @interface ViewController : UIViewController <UITextFieldDelegate> { UITextField *theTextField; UIWindow *statusWindow; } @end 

:

viewController.m

 #import "ViewController.h" @interface ViewController () @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. theTextField = [[UITextField alloc] initWithFrame:CGRectMake(50, 50, 50, 250)]; [theTextField becomeFirstResponder]; theTextField.secureTextEntry = YES;//turn back OFF later (like in `viewDidAppear`) and reset textField properties to YES (like auto correct, auto caps, etc). theTextField.delegate = self; [self.view addSubview:theTextField]; //UIWindow *statusWindow; MUST be defined in .h file! statusWindow = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; statusWindow.frame = CGRectMake(37, self.view.frame.size.height-47, 45, 45); statusWindow.windowLevel = UIWindowLevelStatusBar; statusWindow.hidden = NO; statusWindow.backgroundColor = [UIColor clearColor]; UIButton *keyboardCover = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 45, 45)]; keyboardCover.backgroundColor = [UIColor redColor]; [statusWindow addSubview:keyboardCover]; //statusWindow.alpha = 1.00; statusWindow.userInteractionEnabled = YES; [statusWindow makeKeyAndVisible]; } -(void)viewDidAppear:(BOOL)animated { [theTextField resignFirstResponder]; theTextField.secureTextEntry = NO; theTextField.autocorrectionType = 2;//ON theTextField.autocapitalizationType = 2;//ON theTextField.spellCheckingType = 2;//ON [theTextField becomeFirstResponder]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } @end 





:




Here is an example of how this code will look ... I used a custom keyboard when I launched an application that forced me to an Apple keyboard, and then put a red square on the “change keyboard” button, which made me unable to click on the button, to change the keyboard. (The red square can be changed to be anything, for example, a blank key or a globe icon in a faded (disconnected) state.)



enter image description here

+1
source share

Apple provides an API for this. Put it in your AppDelegate

 - (BOOL)application:(UIApplication *)application shouldAllowExtensionPointIdentifier:(NSString *)extensionPointIdentifier { if ([extensionPointIdentifier isEqualToString:@"com.apple.keyboard-service"]) { return NO; } return YES; } 

This is the cleanest and most documented way to do this :)

+15
source share

As far as I know, there is no way to do this. However, if you are ready to do your best, you can create your own input view that mimics the standard Apple keyboard and use it instead. For more information on input representations, see documentation .

+1
source share

All Articles