Lisplog

I've been writing a custom iOS keyboard for Learning Touch, a novel way of entering text that we're hoping will be easier for people with non-steady hands, though it works fine for the rest of us, too. Can't give any more details until the patent request has been filed, but that will be soon.

I lay out the keyboard myself, with sizes designed to work on a standard 768x1024 pixel iPad, and scaled to the screen size of the device on which it's running. This works fine, for apps that have been updated for each device's screen size, but it failed for old apps that were scaled and/or run in letterbox mode; the keyboard was too wide, so part of it was invisible off the right edge of the screen.

I was just using the hardware bounds, in logical pixels. I needed to scale to the view size, which is narrower for scaled apps. The simple (Swift) code below takes the hardware size from UIScreen.mainScreen.bounds.size and the parent view size (that view is set outside this function and referenced with the getParentView() call).

Strangely, I found no hint of this algorithm in a bunch of Google searches, so I'm posting it, to hopefully make it easier for the next guy to find.