2014-09-05 7 views
0

작곡가 또는 스토리 보드로 장면을 변경할 수 없습니다. tableview에서 행을 만질 때 장면을 변경하려고합니다. 주 파일에서 테이블 뷰로 파일을 변경할 수 있습니다. 테이블 뷰 터치가 작동하지 않습니다. 코로나 SDK onRowTouch gotoScene

내 코드의 일부

은 다음과 같습니다 :

local widget = require("widget") 
    local storyboard = require("storyboard") 
    local composer = require("composer") 
    local scene = composer.newScene() 


function RowTouch(event) 
    composer.gotoScene("thehike") 
end 



myTable = widget.newTableView 
    { 
     width = display.contentWidth, 
     height = display.contentHeight, 
     backgroundColor = { .47, .66, .53 }, 
     topPadding = 0, 
     hideBackground = false, 
     onRowRender = onRowRender, 
     onRowTouch = RowTouch, 
     noLines = true, 
    } 



    for i=1, #hike do 
     myTable:insertRow{ 
     rowHeight = 220, 
     isCategory = false, 
     lineColor = { .47, .66, .53 } 
     } 
    end 
end 

function scene:show(event) 
    local sceneGroup = self.view 
    local phase = event.phase 

    if phase == "will" then 
     -- Called when the scene is still off screen and is about to move on screen 
    elseif phase == "did" then 
     -- Called when the scene is now on screen 
     -- 
     -- INSERT code here to make the scene come alive 
     -- e.g. start timers, begin animation, play audio, etc. 
    end 
end 

function scene:hide(event) 
    local sceneGroup = self.view 
    local phase = event.phase 

    if event.phase == "will" then 
     -- Called when the scene is on screen and is about to move off screen 
     -- 
     -- INSERT code here to pause the scene 
     -- e.g. stop timers, stop animation, unload sounds, etc.) 
    elseif phase == "did" then 
     -- Called when the scene is now off screen 
    end 
end 

function scene:destroy(event) 
    local sceneGroup = self.view 

    -- Called prior to the removal of scene's "view" (sceneGroup) 
    -- 
    -- INSERT code here to cleanup the scene 
    -- e.g. remove display objects, remove touch listeners, save state, etc. 
end 

--------------------------------------------------------------------------------- 

-- Listener setup 
scene:addEventListener("create", scene) 
scene:addEventListener("show", scene) 
scene:addEventListener("hide", scene) 
scene:addEventListener("destroy", scene) 

----------------------------------------------------------------------------------------- 

return scene 

답변

1

코드는 몇 가지 이유가 작동하지 않습니다. 34 번 줄에 매달려 end이 있는데 하이킹을 정의하지 않았습니다. 당신은 아마 당신의보기에서 행을 보여주기 위해 작은 rowHeight에 필요합니다

local myTable = widget.newTableView 
    { 
     left = 0, 
     top = 0, 
     height = 330, 
     width = 300 
    } 

myTable:insertRow(
     { 
      isCategory = false, 
      rowHeight = 40, 
      rowColor = rowColor, 
      lineColor = {.47, .66, .53} 
     } 
    ) 

또한, 문서가이 꽤 좋다 [1].

[1] http://docs.coronalabs.com/api/library/widget/newTableView.html