Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to handle UITextField inside a keyboard app extension

I have added textfield (keyboardTextField) and UISwitch on top of my custom keyboard. I can set focus ON or OFF for (keyboardTextField) on the base of Switch value my code.

- (void)switchToggled:(id)sender
 {
    UISwitch *mySwitch = (UISwitch *)sender;
    if ([mySwitch isOn])
    {
       [keyboardTextField becomeFirstResponder];
    }
    else
    {
        [keyboardTextField resignFirstResponder];
    }
 }

So whats happening right now at first time when my custom keyboard launch its working in each app of my device,But it's impossible for me to select the input view of the main app back after changing Switch value to On and then OFF and now my custom keyboard can't write any thing in any app of my device.

This type of questions already has been asked here and here but no one answered yet. If someone have any workaround or any ideas, Please share.

like image 852
jamil Avatar asked Jan 14 '15 03:01

jamil


1 Answers

I'm making an extension keyboard for IOS and have same problem like you. My purpose is to add an UISearchBar to keyboard like this app but I could not find an answer in any forum where I posted this question.

I even asked Apple Technical support but they answered that this is a bug of iOS keyboard extension.

Last day I found an app is Kanvas keyboard and I think a have my solution, and that's use an UILabel instead UITextField or UISearch in the extension. That will keep my app work fine. Hope this can help you.

like image 151
lufutu Avatar answered Nov 14 '22 22:11

lufutu