Keyboard Not Showing after Moving Textfield

Hello,

In my app, I have a textfield which is usually covered by the keyboard. To avoid this, I shift the display up and recreate the text field above when the user clicks on the text field. I also utilize the setKeyboardFocus function so that the user does not have to click on the field again to begin typing.

While this code works perfectly on android devices, the keyboard does not open on either the XCode simulator and iOS devices. Even when I click on the new text field, I do not get the keyboard.

If I remove the native.setKeyboardFocus( answerField ) line, the keyboard does show up after clicking on the new text field.

Any suggestions are greatly appreciated. Thanks!

Code:

[lua]

function userInputListener( event )
    if event.phase == “began” then
        transition.to(localGroup, {y = -100, time=500})
        if textBox then
            textBox:removeSelf()
            textBox = nil
        end
        textBox = native.newTextBox( 24, 56, 352, 135) --244
        textBox.font = native.newFont( “Helvetica-Bold”, 20 )
        textBox:setTextColor( 255, 255, 255 )
        --textBox.alpha = 1.0
        textBox.hasBackground = false
        textBox:addEventListener( “tap”, removeKeyboard )
        textBox.text = text
        storedText = tostring(event.target.text)
        native.setKeyboardFocus( nil )
        if answerField then
            answerField:removeSelf()
            answerField = nil
        end
        answerField = native.newTextField( 25, 214, 275, 38)
        answerField.size =  fontSize
        answerField.text = storedText
        answerField:addEventListener( “userInput”, shiftedListener )
        answerField.inputType = “decimal”
        
    
        native.setKeyboardFocus( answerField )
    end
    if event.phase == “submitted” or event.phase == “ended” then
        submittedAnswer = tostring(event.target.text)
        if(submittedAnswer:lower() == tostring(answer):lower())then
            correct = 1
            --local t = display.newText(“Correct”, 80, 310, null, 16)
        else
            correct = 0
        end

    end
end

[/lua]

Look to see if the view hierarchy has become messed up. You can easily see this in the ‘document outline.’

f you don’t see this pane, look on the left, bottom side of the storyboard and click the small arrow pointing to the left.

Why not simply move the existing field instead of destroying/creating new ones?   There is probably some issues with trying to do things with textfields while deleteing the text field you’re currently in.  I also don’t know if you can add tap handlers to native objects like that either.

@walkerjon723, I don’t understand how your answer is helping here?  This sounds like something that might be for native develoopers writing objective C using X-Code.  Corona SDK doesn’t work this way.

Rob

Look to see if the view hierarchy has become messed up. You can easily see this in the ‘document outline.’

f you don’t see this pane, look on the left, bottom side of the storyboard and click the small arrow pointing to the left.

Why not simply move the existing field instead of destroying/creating new ones?   There is probably some issues with trying to do things with textfields while deleteing the text field you’re currently in.  I also don’t know if you can add tap handlers to native objects like that either.

@walkerjon723, I don’t understand how your answer is helping here?  This sounds like something that might be for native develoopers writing objective C using X-Code.  Corona SDK doesn’t work this way.

Rob