TableView Group下面多出一行空白

设置UITableView footer高度
本文介绍如何将UITableView的footer高度设置为0.1,并保持其随头部一起移动的方法。

系统默认给的heightForFooterInSection 把他设置为0.1即可
head随着头部移动,设置为plain

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { if isVMS { if isNewMessageCenterUI { guard let cell = tableView.dequeueReusableCell(withIdentifier: MessageManagerPublic.MessageCenterMainCellIdentifier, for: indexPath) as? MessageCenterMainCell else { return MessageCenterMainCell() } cell.selectionStyle = .none if indexPath.section == systemMessageCellSection { cell.setCellBy(messageType: .system, message: nil, unreadUnm: 0) return cell } else if indexPath.section == eventMessageCellSection { //此行为event if let message = appContext.getVmsFirstMessage(by: .event) { cell.setCellBy(messageType: .event, message: message, unreadUnm: Int(appContext.getVmsMessageUnreadNum(by: .event))) return cell } else { //为空 cell.setCellBy(messageType: .event, message: nil, unreadUnm: 0) return cell } } else if indexPath.section == statusMessageCellSection { //此行为status if let message = appContext.getVmsFirstMessage(by: .status) { cell.setCellBy(messageType: .status, message: message, unreadUnm: Int(appContext.getVmsMessageUnreadNum(by: .status))) return cell } else { //为空 cell.setCellBy(messageType: .status, message: nil, unreadUnm: 0) return cell } } } else { let section = indexPath.section if section < siteListDataSource.count { let curSite = siteListDataSource[section] guard let cell = tableView.dequeueReusableCell(withIdentifier: MessageManagerPublic.deviceListCellIdentifier, for: indexPath) as? MessageManagerDeviceListTableViewCell else { return MessageManagerDeviceListTableViewCell() } cell.setupSiteCell(with: curSite) cell.rowInSection = 1 cell.deviceType = .IPC cell.indexPath = indexPath as NSIndexPath return cell } } return UITableViewCell() } let vmsSystemMessageArr = appContext.getvmsSystemMessageList() if indexPath.section == 0 { //第一个section可能是系统消息 if hasSystemSection { guard let cell = tableView.dequeueReusableCell(withIdentifier: MessageManagerPublic.deviceShareMessageListCellIdentifier, for: indexPath) as? MessageManagerDeviceShareMessageListTableViewCell else { return MessageManagerDeviceShareMessageListTableViewCell() } //存在系统消息,但是要看第一条消息是分享消息还是vms邀请消息 let messageSection = dataSource[0] if messageSection.sectionType.rawValue == 1 { //存在分享消息 let group = messageSection.group(at: 0) if let VmsSysMessage = vmsSystemMessageArr.max(by: { $0.llCreateTime < $1.llCreateTime }), Double(VmsSysMessage.llCreateTime)/1000 > group.latestDeviceTime { //显示vms消息 let unreadNumber = Int(appContext.getVmsSystemMessageNewUnreadCount()) + group.unreadCount cell.setupCell(with: VmsSysMessage, unreadNumber: unreadNumber) cell.rowInSection = 1 cell.indexPath = indexPath as NSIndexPath return cell } else { //显示设备分享消息 cell.setupCell(with: group) cell.unreadNumber = Int(appContext.getVmsSystemMessageNewUnreadCount()) + group.unreadCount cell.rowInSection = messageSection.groupCount() cell.indexPath = indexPath as NSIndexPath return cell } } else { //不存在分享消息 if let VmsSysMessage = vmsSystemMessageArr.max(by: { $0.llCreateTime < $1.llCreateTime }){ cell.setupCell(with: VmsSysMessage, unreadNumber: Int(appContext.getVmsSystemMessageNewUnreadCount())) cell.rowInSection = 1 cell.indexPath = indexPath as NSIndexPath return cell } else { return UITableViewCell() } } } else { //显示空白 let messageSection = dataSource[indexPath.section] let group = messageSection.group(at: indexPath.row) if messageSection.sectionType.rawValue == 0 { guard let cell = tableView.dequeueReusableCell(withIdentifier: MessageManagerPublic.deviceListCellIdentifier, for: indexPath) as? MessageManagerDeviceListTableViewCell else { return MessageManagerDeviceListTableViewCell() } cell.setupCell(with: group) cell.rowInSection = messageSection.groupCount() cell.deviceType = messageSection.deviceType cell.indexPath = indexPath as NSIndexPath return cell } } } //其余section let messageSection = dataSource[indexPath.section] let group = messageSection.group(at: indexPath.row) if messageSection.sectionType.rawValue == 0 { guard let cell = tableView.dequeueReusableCell(withIdentifier: MessageManagerPublic.deviceListCellIdentifier, for: indexPath) as? MessageManagerDeviceListTableViewCell else { return MessageManagerDeviceListTableViewCell() } cell.setupCell(with: group) cell.rowInSection = messageSection.groupCount() cell.deviceType = messageSection.deviceType cell.indexPath = indexPath as NSIndexPath return cell } return UITableViewCell() }func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { tableView.deselectRow(at: indexPath, animated: true) if isVMS { if isNewMessageCenterUI { if indexPath.section == systemMessageCellSection { let vc = MessageCenterSystemMessageListViewController() self.navigationController?.pushViewController(vc, animated: true) return } else if indexPath.section == eventMessageCellSection { if let _ = appContext.getVmsFirstMessage(by: .event) { let vc = MessageCenterMessageListViewController() vc.allMessageType = .event let eventMessageNavi = BaseNavigationController(rootViewController: vc) self.splitViewController?.showDetailViewController(eventMessageNavi, sender: self) } } else if indexPath.section == statusMessageCellSection { if let _ = appContext.getVmsFirstMessage(by: .status) { let vc = MessageCenterMessageListViewController() vc.allMessageType = .status let statusMessageNavi = BaseNavigationController(rootViewController: vc) self.showDetailViewController(statusMessageNavi, sender: self) } } } else { if indexPath.section < siteListDataSource.count { selectedSite = siteListDataSource[indexPath.section] performSegue(withIdentifier: MessageManagerPublic.jumpToMessageListSegueIdentity, sender: nil) } } return } let messageSection = dataSource[indexPath.section] let group = dataSource[indexPath.section].group(at: indexPath.row) if messageSection.sectionType.rawValue == 0 { performSegue(withIdentifier: MessageManagerPublic.jumpToMessageListSegueIdentity, sender: group) } else { performSegue(withIdentifier: MessageManagerPublic.jumpToDeviceShareMessageListSegueIdentity, sender: group) print("进入分享消息页面") } } func tableView(_ tableView: UITableView, shouldHighlightRowAt indexPath: IndexPath) -> Bool { return true } 请帮我完整修改代码 要求实现被点击是灰色背景持续显示
最新发布
11-06
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值