Quick-Cocos2d-x3.2 UIpageViewシンプル


この例は公式の例の一つです.ここでは簡単に注釈をつけた.
local TestUIPageViewScene = class("TestUIPageViewScene",function()
    return display.newScene("TestUIPageViewScene")
end)

-- ctor  cocos init() 
function TestUIPageViewScene:ctor()
    
	self:createPageView()
end


function TestUIPageViewScene:createPageView()

    self.pv = cc.ui.UIPageView.new({
        viewRect = cc.rect(80,280,780,480) ,  -- 
        column = 3 , row = 3,                       -- 
        padding = {left = 20 , right = 20 , top = 20 , bottom = 20} , -- 
        columnSpace = 10 , rowSpace = 10                                        -- 
    })
    :onTouch(handler(self,self.touchListener))
    :addTo(self)
    
    for i = 1 , 18 do
    	       local item = self.pv:newItem()
    	       local content
        content = display.newColorLayer(
        cc.c4b(math.random(250),
        math.random(250),
        math.random(250),
        math.random(250)))
        
        content:setContentSize(240 , 140)
        content:setTouchEnabled(false)
        item:addChild(content)      --  item 
        self.pv:addItem(item)          -- pageview item
    end
    
    self.pv:reload()            -- 
	
end


function TestUIPageViewScene:touchListener(event)
    dump(event , "TestUIPageViewScene - event")
    local listView = event.listView
    if 3 == event.itemPos then
    	   listView:removeItem(event.item,true)
    	
    end

	
end

return TestUIPageViewScene

原文:http://blog.csdn.net/qqmcy/article/details/40428583