iOS swift tableView插入cell
ios 插入 swift cell tableView
2023-09-14 09:04:14 时间
注意:count(返回的row数)要加1,在返回cell的代理方法中要返回你要插入的cell
let indexPath1:IndexPath = IndexPath.init(row: 1, section: 0)
tableView.beginUpdates()
count += 1
tableView.insertRows(at: [indexPath1], with: .fade)
tableView.endUpdates()
var count = 4
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
if section == 0 {
return count
} else {
return 2
}
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
if indexPath.section == 0 && indexPath.row == 1 {
if count == 5 {
let cell3:settingCell3 = tableView.dequeueReusableCell(withIdentifier: "cell3", for: indexPath) as! settingCell3
return cell3
}
let cell2: settingCell2 = tableView.dequeueReusableCell(withIdentifier: "cell2", for: indexPath) as! settingCell2
cell2.titleLabel.text = NSLocalizedString("softwareSecurity", comment: "")
return cell2
}
}
参考博客:
UITableView 动态增加删除行
相关文章
- iOS小技能:NSLog调试技巧
- iOS小技能:地理编码(地址转坐标)
- 备份从android到ios系统文件,如何将音乐从安卓设备转移到iOS设备中「建议收藏」
- IOS – OpenGL ES 同心圆像素化马赛克效果 GPUImagePolarPixel
- 【iOS 开发】iOS 开发 简介 (IOS项目文件 | MVC 模式 | 事件响应机制 | Storyboard 控制界面 | 代码控制界面 | Retina 屏幕图片适配)
- ios免费开发者账号
- 写给iOS程序员的命令行使用秘籍详解手机开发
- iOS内存管理浅析详解手机开发
- iOS判断一个字符是不是中文字符,计算一段字符串的长度。详解手机开发
- Linux与iOS之间的技术对比(linux和ios)
- Linux技术可以开发IOS系统?(linux能开发ios吗)
- 让Linux开发iOS应用变得更简单(linux开发ios应用)
- Linux与iOS:越来越亲密的合作伙伴(linux与ios)
- iOS 14最新版翻车:苹果iPhone 12系列续航大幅缩水
- iOS 不是 Linux,而是苹果独特操作系统(ios是linux吗)
- IOS系统有支持Oracle吗(ios支持oracle吗)
- 使用iOS就能操作Oracle数据库(ios上oracle)
- 谁说 iOS 就不适用Oracle(ios oracle软件)
- iOS系统下的Oracle数据库环境(ios oracle)