ios - UITextInputMode currentInputMode is deprecated. Suggested replacement? -
in our app, we'd detect current keyboard language. example, if user sets multiple language keyboards under settings->general->keyboard->keyboards, we'd know language they're typing in , notification nsnotificationcenter when changes.
- (void)viewdidload { [super viewdidload]; nsnotificationcenter *ncenter = [nsnotificationcenter defaultcenter]; [ncenter addobserver:self selector:@selector(languagechanged:) name:uitextinputcurrentinputmodedidchangenotification object:nil]; [self languagechanged:nil]; } -(void)languagechanged:(nsnotification*)notification { for(uitextinputmode *mode in [uitextinputmode activeinputmodes]) { nslog(@"input mode: %@", mode); nslog(@"input language: %@", mode.primarylanguage); } nslog(@"notification: %@", notification); uitextinputmode *current = [uitextinputmode currentinputmode]; nslog(@"current: %@", current.primarylanguage); }
what we've discovered code notification fires appropriately when user toggles keyboards using globe icon on keyboard, when iterate uitextinputmodes, appear in same order no (apparent) indication of current 1 unless use now-deprecated [uitextinputmode currentinputmode].
i can't find documentation indicating apple's suggested alternative now-deprecated functionality. there several threads mentioning deprecation, none found solutions. ideas? in advance.
the object notification uitextinputcurrentinputmodedidchangenotification instance of uitextinputmode.
uitextinputmode *currentinputmode = [notification object];
also, can active input mode on particular responder:
uitextview *textview = [[uitextview alloc] init]; uitextinputmode *currentinputmode = textview.textinputmode;
currently on ios 7, textinputmode/notification object nil emoji keyboard. it's unclear if intended behaviour.
Comments
Post a Comment