local MainScene = class("MainScene", cc.load("mvc").ViewBase)

function MainScene:onCreate()

    local im = ccui.ImageView:create("HelloWorld.png")
self:addChild(im)
im:setPosition(,) local scene = self local list = {}
for i=, do
table.insert(list,i.."号位")
end
dump(list) local tableSize = cc.size(,)
local cellSize = cc.size(tableSize.width, )
local tv = cc.TableView:create(tableSize)
self:addChild(tv)
tv:setPosition(,)
tv:setScale(1.5) local function tableCellAtIndex(table, idx)
--print("tableCellAtIndex"..idx)
local cell = table:dequeueCell()
if cell then
--cell:removeAllChildren()
else
cell = cc.TableViewCell:create() local ly = ccui.Layout:create()
ly:setBackGroundColorType()
ly:setBackGroundColor({r = , g = , b = })
ly:setBackGroundColorOpacity()
local layout = ccui.LayoutComponent:bindLayoutComponent(ly)
layout:setSize({width = cellSize.width,height =cellSize.height-})
cell:addChild(ly) cell.oneItem= ccui.Text:create("","",)
cell.oneItem:setFontSize()
cell.oneItem:setfont
cell.oneItem:setColor(cc.c3b(,,))
cell:addChild(cell.oneItem,)
cell.oneItem:setPosition(,) cell.btn = ccui.Button:create("btn.png")
cell.btn:setAnchorPoint(cc.p(,))
cell:addChild(cell.btn,)
cell.btn:setSwallowTouches(false) local function btnClick(sender, state)
--print("btn "..cell.btn:getTag())
local event = {}
if state == then
event.name = "began"
tv.ScorllState = false
elseif state == then
event.name = "moved"
elseif state == then
event.name = "ended"
if tv.ScorllState == false then
print("btn click "..cell.btn:getTag())
end
else
event.name = "cancelled"
end print(event.name)
end
--cell.btn:addClickEventListener(btnClick)
cell.btn:addTouchEventListener(btnClick)
end cell.btn:setTag(idx+)
cell.oneItem:setString(list[idx+]) return cell
end
local function cellSizeForIndex(table, idx)
--print("cellSizeForIndex"..idx)
return cellSize.width, cellSize.height
end
local function numberOfCellsInTableView(table)
--print("numberOfCellsInTableView")
return #list
end local function tableDidScroll(table)
--print("tableDidScroll")
tv.ScorllState = true
end
tv:setDelegate()
tv:registerScriptHandler(cellSizeForIndex, cc.TABLECELL_SIZE_FOR_INDEX)
tv:registerScriptHandler(tableCellAtIndex, cc.TABLECELL_SIZE_AT_INDEX)
tv:registerScriptHandler(numberOfCellsInTableView, cc.NUMBER_OF_CELLS_IN_TABLEVIEW)
tv:registerScriptHandler(tableDidScroll, cc.SCROLLVIEW_SCRIPT_SCROLL) tv:reloadData() end return MainScene

TableView+Button的更多相关文章

  1. iOS 在tableView上添加button导致按钮没有点击效果和不能滑动的 zhuang

    转载请注明出处. 今天在调试代码的时候,在tableviewcell上添加button,发现button快速点击的话,是看不出点击效果的,查找资料发现, ios7上UITableViewCell子层容 ...

  2. iOS实现类似QQ的好友列表,自由展开折叠(在原来TableView的基础上添加一个字典,一个Button)

    //直接代码 只包含 折叠展开字典的处理搭建#import "CFViewController.h" @interface CFViewController ()<UITab ...

  3. 【iOS开发-68】APP下载案例:利用tableView自带的cell布局+缓存池cell复用时注意button状态的检查

    (1)效果 (2)源码与资源下载 http://pan.baidu.com/s/1pJLo2PP (3)总结 --核心是利用UITableView里面自带的cell来制作样式同样的cell. 与之对应 ...

  4. 取到 tableview 自定义section header 上的button

    在自定义的组头上,添加了一个button,在点击cell是想取到相应的组头上的button来进行操作时(比如说隐藏.是否响应点击事件等)时,我遇到了取不到所有button的问题,试过了常规的通过vie ...

  5. 使用tableview的表头button 实现多 cell 的选择

    首先声明本篇博文是作者原创,在QQ群里看到一枚猿友求助,问题描述:使用UItableView 实现在表头里点击不同的按钮,去刷新当前的界面(界面是大的 cell),自己就实现了一下. 实验原材料:故事 ...

  6. 如何对tableview进行自定义多选

    前言: 很多入门不久的程序员或许都会遇到系统自带的tableview多选时cell选择时不能选择自己想要的点击时的颜色或者图片,这让初级开发者们很烦恼.今天,我试着花了几个小时的时间用了自己的想法,去 ...

  7. 在TableView上添加悬浮按钮

    如果直接在TableVIewController上贴Button的话会导致这个会随之滚动,下面解决在TableView上实现位置固定悬浮按钮的两种方法: 1.在view上贴tableView,然后将悬 ...

  8. IOS 中列表的TableView 详解,常用方法整理

    一.创建一个列表,不管代码还是nib拖拉,在nib创建的时候,记得加他的二个代理 (UITableViewDelegate UITableViewDataSource) 代码创建的话,需要关联他的代理 ...

  9. TableViewCell,TableView,UITableViewCell

    这次的学习是在Navigation-based Application模板中,用RootViewController class设置操作方法,使用UITableView的属性值.在导航控制器控件为程序 ...

随机推荐

  1. flutter 本地存储 (shared_preferences)

    Flutter本地存储 和Android.Ios类似,Flutter也支持Preferences(Shared Preferences and NSUserDefaults) .文件.和Sqlite3 ...

  2. centos下安装nginx并部署angular应用

    注意:直接yum安装的nginx有问题,不能直接安装,因为centos默认库里面没有nginx.如果安装过程中出现一些文件夹或者文件找不到的话,应该是你的nginx的版本没有安装对.最效率的办法是删除 ...

  3. [转帖]御界预警:3700余台SQL服务器被入侵挖矿 或导致严重信息泄露事件

    御界预警:3700余台SQL服务器被入侵挖矿 或导致严重信息泄露事件 https://zhuanlan.kanxue.com/article-8292.htm sqlserver的弱密码破解和提权攻击 ...

  4. git异常操作解决办法合集

    1. git add .后发现提交错误,想撤销 git reset head 文件名-----撤销某个文件 git reset head --hard 强制撤销当前的所有操作到上次提交的版本 2. g ...

  5. springboot使用RestHighLevelClient批量插入

    1.引入maven(注意版本要一致) <dependency> <groupId>org.springframework.boot</groupId> <ar ...

  6. Codeforces #402

    目录 Codeforces #402 Codeforces #402 Codeforces 779A Pupils Redistribution 链接:http://codeforces.com/co ...

  7. fast-ai lesson1 错误处理(CNN创建)

    报错信息: name 'ConvLearner' is not defined 在最新的fast ai包中,ConvLearner已经被create_cnn取代,所以替换为下列语句就好了: learn ...

  8. jumpserver win终端无法添加

    今天遇到一个问题是,guacd,tomcat部署完成以后jumpserver终端管理页里面还是只有coco的终端而没有guacd的终端

  9. session常用对象

    1.object getArrtibute(String name) 获取与名字name相联系的属性 2.void setArrtibute(String name,object) 设置指定名字的属性 ...

  10. 01-oracle学习环境配置

    1.安装oracle与SQL Developer oracle10g安装教程 2.创建表空间以及用户 表空间是存储数据文件的容器,由数据文件组成,数据库的所有系统数据和用户数据都必须存储在数据文件中. ...