I want to detect current input mode of keyboard, and change text direction with respect to it (rtl if arabic, and ltr if english) in viewDidLoad:
- (void)viewDidLoad {
[super viewDidLoad];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(changeInputMode:)
name:UITextInputCurrentInputModeDidChangeNotification object:nil];
} and in changeInputMode:
-(void)changeInputMode:(NSNotification *)notification
{
UITextInputMode *thisInputMode = [notification object];
NSLog(@"inputMethod=%@",thisInputMode);
}
but thisInputMode is nill! if I use this code instead:
NSString *inputMethod = [[UITextInputMode currentInputMode] primaryLanguage];
NSLog(@"inputMethod=%@",inputMethod);
it works fine and detects current password, but currentInputMode is deprecated. why [notification object] returns nill?
Aucun commentaire:
Enregistrer un commentaire