0

私は director を使用して、あるシーンから別のシーンに移動しています。どのシーンに移動しても、intor のボタンとテキスト フィールドが画面の上部に表示されるという問題があります。

次のシーンに移動する前に項目 (テキスト フィールド、intro.lua 画面からの btns) を削除するには?

    enter code here    
-- into.lua
module(..., package.seeall)
function new()
--
-- Project: NativeKeyboard2
--

local widget = require( "widget" )

require("hijacks")

local tHeight       -- forward reference

-------------------------------------------
-- General event handler for fields
-------------------------------------------

-- You could also assign different handlers for each textfield

local function fieldHandler( textField )
    return function( event )
        if ( "began" == event.phase ) then
            -- This is the "keyboard has appeared" event
            -- In some cases you may want to adjust the interface when the keyboard appears.

        elseif ( "ended" == event.phase ) then
            -- This event is called when the user stops editing a field: for example, when they touch a different field

        elseif ( "editing" == event.phase ) then

        elseif ( "submitted" == event.phase ) then
            -- This event occurs when the user presses the "return" key (if available) on the onscreen keyboard
            print( textField().text )

            -- Hide keyboard
            native.setKeyboardFocus( nil )
        end
    end
end

-- Predefine local objects for use later
local nameField, phoneField
local fields = display.newGroup()



-------------------------------------------
-- *** Create native input textfields ***
-------------------------------------------

-- Note: currently this feature works in device builds or Xcode simulator builds only (also works on Corona Mac Simulator)
local isAndroid = "Android" == system.getInfo("platformName")
local inputFontSize = 18
local inputFontHeight = 30
tHeight = 30

if isAndroid then
    -- Android text fields have more chrome. It's either make them bigger, or make the font smaller.
    -- We'll do both
    inputFontSize = 14
    inputFontHeight = 42
    tHeight = 40
end

nameField = native.newTextField( 40, 120, 200, tHeight )
nameField.font = native.newFont( native.systemFontBold, inputFontSize )
nameField:addEventListener( "userInput", fieldHandler( function() return nameField end ) ) 

phoneField = native.newTextField( 40, 160, 200, tHeight )
phoneField.font = native.newFont( native.systemFontBold, inputFontSize )
phoneField.inputType = "phone"
phoneField:addEventListener( "userInput", fieldHandler( function() return phoneField end ) ) 


-- Add fields to our new group
fields:insert(nameField)
fields:insert(phoneField)

-------------------------------------------
-- *** Add field labels ***
-------------------------------------------

local defaultLabel = display.newText( "الاسم", 250, 120, native.systemFont, 18 )
defaultLabel:setTextColor( 255, 0, 0 )

local defaultLabel = display.newText( "رقم الجوال", 250, 160, native.systemFont, 18 )
defaultLabel:setTextColor( 255, 0, 0 )

-- -------------------------------------------
-- -- Create a Background touch event
-- -------------------------------------------


local listener = function( event )
    -- Hide keyboard
    print("tap pressed")
    native.setKeyboardFocus( nil )

    return true
end

-- Determine if running on Corona Simulator
--
local isSimulator = "simulator" == system.getInfo("environment")
if system.getInfo( "platformName" ) == "Mac OS X" then isSimulator = false; end

-- Native Text Fields not supported on Simulator
--
if isSimulator then
msg = display.newText( "الرجاء ادخال اسمك ورقم جوالك", 0, 280, native.systemFontBold, 12 )
msg.x = display.contentWidth/2      -- center title
msg:setTextColor( 255,0,0 )
end

-- -- Add listener to background for user "tap"
-- bkgd:addEventListener( "tap", listener )
-- display.remove( obj )
-- obj = nil    

local introGroup = display.newGroup();

    local background = display.newImage("graphics/intro_background.png")        
    local begin = display.newImage("graphics/begin_button.png")
    begin.x = 160; 
    begin.y = 400;
    begin.scene = "menu";

    introGroup:insert(background);
    introGroup:insert(begin);

    begin:addEventListener("touch", changeScene)

return introGroup;

end
4

1 に答える 1