tasty-imitation-keyboard icon indicating copy to clipboard operation
tasty-imitation-keyboard copied to clipboard

How to change between two keyboards?

Open mikrosk opened this issue 8 years ago • 13 comments

I was very kindly surprised how universal processing of the Keyboard class is. I can define my own layout, my custom types, with all the colours, letters, images, amazing.

I've been wondering, is there a way how to switch between them? From what I've seen it seems the controller initializes the layout only once and then just hides/shows the default settings, if needed.

I haven't done much experiments with it yet but if you can give me some hints, I'll appreciate that. :)

Keep up the great work!

mikrosk avatar Jun 14 '16 06:06 mikrosk

I've done some work allowing the user to flip between layouts: https://github.com/polishedcode/tasty-imitation-keyboard

simoncorstonoliver avatar Jun 14 '16 13:06 simoncorstonoliver

That's great stuff, mate! However, I'm experiencing much more unstable behaviour with your version, esp. when I start it in the simulator (iOS 9.3) -- many times I'm unable to switch back to the original keyboard, I mean literally the globe button does nothing, I have to restart the simulator in some cases. As soon as I try the original code, it works fine.

mikrosk avatar Jun 20 '16 23:06 mikrosk

Yeah the behavior of the switching a bit twitchy. You have to long press the globe button and slide along to the pop up. Tapping on the button is a bit unreliable.

On Mon, Jun 20, 2016 at 4:32 PM, Miro Kropacek [email protected] wrote:

That's great stuff, mate! However, I'm experiencing much more unstable behaviour with your version, esp. when I start it in the simulator (iOS 9.3) -- many times I'm unable to switch back to the original keyboard, I mean literally the globe button does nothing, I have to restart the simulator in some cases. As soon as I try the original code, it works fine.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/archagon/tasty-imitation-keyboard/issues/96#issuecomment-227300456, or mute the thread https://github.com/notifications/unsubscribe/ALQ5GclomyEGQ2ksaRrxmvnHvnFCeghzks5qNyL2gaJpZM4I0_Sc .

simoncorstonoliver avatar Jun 20 '16 23:06 simoncorstonoliver

Any idea what's causing it or better, any hope of fixing it? For me, this is a showstopper, even though I love the other features :-( (I'm still a beginner in iOS/Swift).

mikrosk avatar Jun 21 '16 00:06 mikrosk

You can add keyView.addTarget(self, action: #selector(KeyboardViewController.advanceTapped), forControlEvents: .TouchUpInside) under case Key.KeyType.KeyboardChange: in KeyboardViewController

dawand avatar Jun 23 '16 23:06 dawand

Added single tap handler per Dawand@'s comment. Give that a try mikrosk@.

https://github.com/polishedcode/tasty-imitation-keyboard/commit/506d57bf0706d4ab8f164021a9ac1a6517f0c7eb

simoncorstonoliver avatar Jun 25 '16 20:06 simoncorstonoliver

@polishedcode, do you know what is preventing your keyboard from having correct hight with iPad in Landscape? I am not sure whether or not is related, but the debugger also reports auto-layout constraint issues in CatboardBanner.Swift. (I need to do some more poking to identify the exact issues.)

AaronFW avatar Jul 20 '16 16:07 AaronFW

sorry, I haven't done any debugging for iPad yet.

On Wed, Jul 20, 2016 at 9:53 AM, AaronFW [email protected] wrote:

@polishedcode https://github.com/polishedcode, do you know what is preventing your keyboard from having correct hight with iPad in Landscape? I am not sure whether or not is related, but the debugger also reports auto-layout constraint issues in CatboardBanner.Swift. (I need to do some more poking to identify the exact issues.)

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/archagon/tasty-imitation-keyboard/issues/96#issuecomment-234010651, or mute the thread https://github.com/notifications/unsubscribe-auth/ALQ5GYa1VLQ7fcvbOxKWu9TlSYVc2Hevks5qXlKjgaJpZM4I0_Sc .

simoncorstonoliver avatar Jul 20 '16 17:07 simoncorstonoliver

I also have issues with the iPad keyboard height. @polishedcode would it be possible to have a look at it please?

dawand avatar Jul 20 '16 17:07 dawand

@dawand @polishedcode I've been a little slow to get to it, but I've gotten the iPad Landscape Keyboard Height to be acceptable now. (I have not tested it with iPad-Mini since there is no simulator.)

It might be somewhat 'hack' but I basically reused the code for the canonicalPortraitHeight and modified it for landscape and for iPad.

In keyboardViewController.swift, I updated the following function by adding the constant "let actualScreenHeight" and changing the "canonicalLandscapeHeight".

func heightForOrientation(orientation: UIInterfaceOrientation, withTopBanner: Bool) -> CGFloat {

        let actualScreenWidth = (UIScreen.mainScreen().nativeBounds.size.width /
            UIScreen.mainScreen().nativeScale)

        let actualScreenHeight = (UIScreen.mainScreen().nativeBounds.size.height / UIScreen.mainScreen().nativeScale)

        let canonicalPortraitHeight = CGFloat(orientation.isPortrait && actualScreenWidth >= 400 ? 226 : 216)

        let canonicalLandscapeHeight = CGFloat(orientation.isLandscape && actualScreenHeight >= 800 ? 330 : 162)


        let topBannerHeight = (withTopBanner && textDocumentProxy.keyboardType != UIKeyboardType.NumberPad && textDocumentProxy.keyboardType != UIKeyboardType.DecimalPad)
            ? metric("topBanner") : 0

        return CGFloat(orientation.isPortrait ? canonicalPortraitHeight + topBannerHeight : canonicalLandscapeHeight + topBannerHeight)

    }

There might be a better way to do it, or better numbers to use, but this seems to work making the keyboard the right size on iPads and iPhones.

AaronFW avatar Aug 07 '16 15:08 AaronFW

Sounds good. It'll be a few days before I can review the fix.

On Monday, 8 August 2016, AaronFW [email protected] wrote:

@dawand https://github.com/dawand @polishedcode https://github.com/polishedcode I've been a little slow to get to it, but I've gotten the iPad Landscape Keyboard Height to be acceptable now. (I have not tested it with iPad-Mini since there is no simulator.)

It might be somewhat 'hack' but I basically reused the code for the canonicalPortraitHeight and modified it for landscape and for iPad.

In keyboardViewController.swift, I updated the following function by adding the constant "let actualScreenHeight" and changing the "canonicalLandscapeHeight".

func heightForOrientation(orientation: UIInterfaceOrientation, withTopBanner: Bool) -> CGFloat {

    let actualScreenWidth = (UIScreen.mainScreen().nativeBounds.size.width /
        UIScreen.mainScreen().nativeScale)

    let actualScreenHeight = (UIScreen.mainScreen().nativeBounds.size.height / UIScreen.mainScreen().nativeScale)

    let canonicalPortraitHeight = CGFloat(orientation.isPortrait && actualScreenWidth >= 400 ? 226 : 216)

    let canonicalLandscapeHeight = CGFloat(orientation.isLandscape && actualScreenHeight >= 800 ? 330 : 162)


    let topBannerHeight = (withTopBanner && textDocumentProxy.keyboardType != UIKeyboardType.NumberPad && textDocumentProxy.keyboardType != UIKeyboardType.DecimalPad)
        ? metric("topBanner") : 0

    return CGFloat(orientation.isPortrait ? canonicalPortraitHeight + topBannerHeight : canonicalLandscapeHeight + topBannerHeight)

}

There might be a better way to do it, or better numbers to use, but this seems to work making the keyboard the right size on iPads and iPhones.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/archagon/tasty-imitation-keyboard/issues/96#issuecomment-238088911, or mute the thread https://github.com/notifications/unsubscribe-auth/ALQ5Gd2UHHyIve_ZUv3rHnifz8rs99szks5qdfnfgaJpZM4I0_Sc .

simoncorstonoliver avatar Aug 07 '16 21:08 simoncorstonoliver

Included dawand@'s fix.

On Sun, Aug 7, 2016 at 2:29 PM, Simon Corston-Oliver < [email protected]> wrote:

Sounds good. It'll be a few days before I can review the fix.

On Monday, 8 August 2016, AaronFW [email protected] wrote:

@dawand https://github.com/dawand @polishedcode https://github.com/polishedcode I've been a little slow to get to it, but I've gotten the iPad Landscape Keyboard Height to be acceptable now. (I have not tested it with iPad-Mini since there is no simulator.)

It might be somewhat 'hack' but I basically reused the code for the canonicalPortraitHeight and modified it for landscape and for iPad.

In keyboardViewController.swift, I updated the following function by adding the constant "let actualScreenHeight" and changing the "canonicalLandscapeHeight".

func heightForOrientation(orientation: UIInterfaceOrientation, withTopBanner: Bool) -> CGFloat {

    let actualScreenWidth = (UIScreen.mainScreen().nativeBounds.size.width /
        UIScreen.mainScreen().nativeScale)

    let actualScreenHeight = (UIScreen.mainScreen().nativeBounds.size.height / UIScreen.mainScreen().nativeScale)

    let canonicalPortraitHeight = CGFloat(orientation.isPortrait && actualScreenWidth >= 400 ? 226 : 216)

    let canonicalLandscapeHeight = CGFloat(orientation.isLandscape && actualScreenHeight >= 800 ? 330 : 162)


    let topBannerHeight = (withTopBanner && textDocumentProxy.keyboardType != UIKeyboardType.NumberPad && textDocumentProxy.keyboardType != UIKeyboardType.DecimalPad)
        ? metric("topBanner") : 0

    return CGFloat(orientation.isPortrait ? canonicalPortraitHeight + topBannerHeight : canonicalLandscapeHeight + topBannerHeight)

}

There might be a better way to do it, or better numbers to use, but this seems to work making the keyboard the right size on iPads and iPhones.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/archagon/tasty-imitation-keyboard/issues/96#issuecomment-238088911, or mute the thread https://github.com/notifications/unsubscribe-auth/ALQ5Gd2UHHyIve_ZUv3rHnifz8rs99szks5qdfnfgaJpZM4I0_Sc .

simoncorstonoliver avatar Aug 16 '16 03:08 simoncorstonoliver

Correction, it was AaronFW@'s fix. Reading comprehension fail.

simoncorstonoliver avatar Aug 16 '16 03:08 simoncorstonoliver