Would a physical keyboard prevent a inputAccessoryView from appearing? - ios

I've added an inputAccessoryView to the iOS keyboard for certain UITextFields in my app. This accessory view provides essential functionality to the user (some buttons that are displayed nowhere else in my app). My understanding (which could be completely wrong) is that if a physical (bluetooth) keyboard is available iOS will not clutter the screen with the software keyboard. If that's the case, users of my app with a physical keyboard will be missing some functionality and I'll need to account for that. So the first question is, is that something I have to worry about? Thanks.

The input accessory view should appear at the bottom of the screen if a physical keyboard is used, so they will still be able to access the functionality. If you want to try this in the simulator, check the Simulate Hardware Keyboard option under the Hardware menu.

Related

How to detect the Smart/external Keyboard on iPad?

How can one get a notification when a (Smart) keyboard is connected?
Some context:
I am working on a feature that automatically shows and hides my software keyboard based on whether the iPad Pro Smart Keyboard, or another external keyboard is connected or not (like Pages). I have seen this answer but that only applies when a textfield is selected. After a lot of googling, I stumbled into the Apple's ExternalAccessory class which you can ask for connected devices, and then check what these devices are.
I have tried a basic implementation of this and I can't get it to work on my iPad Pro with connected Smart Keyboard (Yes, I am sure it's connected because I can see the letters I type appear on my screen 😅).
First of all, the docs say that you can detect devices that are through over Bluetooth and Lightning, I can only to hope this also includes the Smart Keyboard connector. I have enabled the Wireless Accessory Configuration capability of my project.
Second, one needs to add the UISupportedExternalAccessoryProtocols key to their info.plist, then needs to specify which protocols are connected. Which protocols there are doesn't seem to be documented, also not for Apple's own devices. I ran into a tutorial that mentioned the iAP2 bluetooth protocol, so I added this and then hoped for the best.
My code
As I haven't set up my project configuration right yet, I didn't add a lot of code either. I tried:
func printAllAccessories() {
for device in EAAccessoryManager.shared().connectedAccessories {
print("connected device with name: ", device.name)
}
}
But noting seems to be connected.
Bottom line
What is the process, including project configuration, to get external keyboard notifications in an iOS App?
There doesn't seem to be any comprehensive documentation of this online so it's probably nice to get that here. Any help would be highly appreciated!
First of all this doesn't work because smart connector is not using bluetooth to connect to device. You can read more about that on this page Use your Smart Keyboard Folio or Smart Keyboard with iPad Pro.
Second thing is that apple Smart Keyboard and external keyboard is totally different thing. Apple Smart Keyboard can be used as iPad case and as iPad keyboard. External keyboard is used only as keyboard and nothing else.
So from this we can conclude that when you connect you Smart Keyboard to iPad with Smart Connector iPad will treat it as iPad case, which gives you protection for your iPad and no other functionality which would impact on your software(try to type on it or use any shortcuts, nothing will work). iPad will recognise Smart Keyboard as keyboard only when it will be folded in type position. This is the main difference from external keyboard. External keyboard will be recognised as soon as you connect it via bluetooth.
Pages app will hide keyboard only if the external keyboard is connected via bluetooth or your Smart Keyboard is in type position. If Smart Keyboard is connected to Smart Connector and is not in type position there will still be software keyboard until you fold it in to type position. This means that iOS will handle hiding and showing keyboard.
For handling key presses performed on hardware keyboard you can refer to this class UIKeyCommand.

Disabling Split Option in iOS5 Keyboard

I am facing problem in my app because of the new split keyboard option in iOS5.
Is there any way we can hide or disable this option in objective C?.
Thanks in advance.
Seems like the split keyboard does not use the same functions as regular keyboard. see here.
missing kb notifications
Here's the problem: You can iterate through the keyboard subviews and hide the button but you can't control the state of the keyboard when going from one app to the next. It would get really tricky and sneaky to force the private api to call when the application did enter foreground and the keyboard became active.
You could do this but apple may deny you from the store.
Fix your view to account for the keyboard movement. Your users will dock or unsplit the keyboard when there's clear disruption in the UI due to the keyboard placement.
Other solutions could be to move the entire view that requires keyboard placement to be docked or undocked using the notifications. See other posting here: StackOverflow article

Has anyone found a good way of using the new iOS5 keyboard events?

During development of a recent feature for my iPad app, I realized that the new iOS5 keyboard docking/splitting behavior was causing huge issues. I use an inputAccessoryView for the keyboard with a text field on it similar to Safari's find on page feature. I display the keyboard over a scrollable UIWebView, so part my troubles come from having a shrunken UIWebview when the keyboard is docked and having a (mostly) fullscreen webview when it is undocked.
The main issues I have run into with the API are that the new UIKeyboardWillChangeFrameNotification and UIKeyboardDidChangeFrameNotification notifications are a step back from the previous API at best, and have garbage data that makes it nearly impossible to understand what the keyboard is really doing in many cases.
Can any of the following keyboard behaviors be recognized without arduously examining the begin/end frames that come back on the notifications?
Keyboard Undocks
Keyboard Docks
Keyboard Splits/Unsplits
Undocked Keyboard Shows
Undocked Keyboard Hides
View rotates while keyboard is undocked
I've come up with some abstractions to recognize frames that are docked or offscreen, but even with that, my code is becoming very unmanageable. If you've found better ways to do this, please answer or comment. I hope I'm missing something here. Thanks.
The thing is not to overthink this. Nothing of any importance has changed. If the keyboard comes into docked position at the bottom of the screen, you will get a "show" notification. If it leaves the docked position at the bottom of the screen, you will get a "hide" notification. That's exactly what happened before iOS 5.
The only difference is that instead of leaving the docked position because it is moving offscreen, it might be leaving the docked position because the user undocked it. You'll still get a "hide", so you can move your interface back into its base position. You don't need to know that the keyboard is now undocked (though you can find out that it is not offscreen from UIKeyboardDidChangeFrameNotification if you really want to). The reason you don't need to know is that when the keyboard is undocked / split, the user can be proactive and move the keyboard if it's in the way of something that needs to be seen.
Thus, all your old code from before iOS 5 continues to work just fine. It's all really quite clever...

bluetooth keyboard override

Is there a way to force up a software keyboard when the user has a iOS bluetooth keyboard device installed?
Or, to that end, is it possible in code to disable a specific bluetooth device?
Thanks!
In most (maybe all?) iOS apps with which I have used Apple's bluetooth keyboard, pressing the eject key (located in the top right corner) will bring up the soft keyboard on the screen. Maybe that little factoid could help you in some way.
Not from within the application's code, if you're planning on getting into the app store. Apple expressly does not provide methods to show or hide keyboard, instead pushing you to use becomeFirstResponder and resignFirstResponder.
You may be able to do this through some non-AppStore-friendly methods, but somehow I don't think that's the answer you're looking for.
(Note - you could make a fake, Apple-looking keyboard when the real one is hidden, and check if the real one is hidden based on whether a view is visible, but if Apple notices you doing this, you'll get denied.)

Show iPhone keyboard programmatically

I want show the iphone keyboard. How can I write the code (programmatically) to show the keyboard.
As Jacob said, you'll have to run becomeFirstResponder on a UITextView to make it the first responder, the object the user's currently working with. If you do this, the iPhone OS automatically shows the keyboard, cause that's what's needed for working with a UITextView from a user perspective.
As others have noted, you send the becomeFirstResponder message to the control that you want the keyboard to edit.
One extra thing you should be aware of is that if you plug an external keyboard into an iPad then the keyboard will not appear on screen. You need to design your view so it doesn't look silly without the on-screen keyboard.

Resources