ios表格第一行是自定义cell.第二行是另外一个自定义cell怎么写
答案:2 悬赏:60
解决时间 2021-02-07 06:54
- 提问者网友:先森请一心
- 2021-02-07 03:08
ios表格第一行是自定义cell.第二行是另外一个自定义cell怎么写
最佳答案
- 二级知识专家网友:懂得ㄋ、沉默
- 2021-02-07 03:59
创建cell 的时候,indexpath.row=0的是时候cell不重用,其他的正常使用就行了
全部回答
- 1楼网友:情战凌云蔡小葵
- 2021-02-07 05:29
实现cell的滑动删除, 需要实现uitableview的代理uitableviewdelegate中如下方法:
//先要设cell可编辑
- (bool)tableview:(uitableview *)tableview caneditrowatindexpath:(nsindexpath *)indexpath
{
return yes;
}
//定义编辑样式
- (uitableviewcelleditingstyle)tableview:(uitableview *)tableview editingstyleforrowatindexpath:(nsindexpath *)indexpath
{
[tableview setediting:yes animated:yes];
return uitableviewcelleditingstyledelete;
}
//进入编辑模式,按下出现的编辑按钮后
- (void)tableview:(uitableview *)tableview commiteditingstyle:(uitableviewcelleditingstyle)editingstyle forrowatindexpath:(nsindexpath *)indexpath
{
[tableview setediting:no animated:yes];
}
以下方法可以不是必须要实现,添加如下方法可实现特定效果:
//修改编辑按钮文字
- (nsstring *)tableview:(uitableview *)tableview titlefordeleteconfirmationbuttonforrowatindexpath:(nsindexpath *)indexpath
{
return @"删除";
}
实现cell可上下移动,调换位置,需要实现uitableviewdelegate中如下方法:
//先设置cell可移动
- (bool)tableview:(uitableview *)tableview canmoverowatindexpath:(nsindexpath *)indexpath
{
return yes;
}
//当两个cell对换位置后
- (void)tableview:(uitableview*)tableview moverowatindexpath:(nsindexpath*)sourceindexpath toindexpath:(nsindexpath*)destinationindexpath
{
}
//设置进入编辑状态时,cell不会缩进
- (bool)tableview: (uitableview *)tableview shouldindentwhileeditingrowatindexpath:(nsindexpath *)indexpath
{
return no;
}
//在下面方法中添加 cell.showsreordercontrol =yes;
//使cell显示移动按钮
- (uitableviewcell*)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath*)indexpath;
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯
• 手机登qq时,显示手机磁盘不足,清理后重新登 |
• 刺客的套装怎么选啊? |