【发布时间】:2021-04-05 05:58:25
【问题描述】:
我正在使用 cocoapod XLPagerTabStrip 在我的 iOS 应用程序中实现 PagerTabStrip。我在构建或运行应用程序时收到以下警告消息
变量“self”被写入,但从未读取
此警告来自以下用于在滑动时更改项目文本颜色的关闭代码。
changeCurrentIndexProgressive = { [weak self] (oldCell: ButtonBarViewCell?, newCell: ButtonBarViewCell?, progressPercentage: CGFloat, changeCurrentIndex: Bool, animated: Bool) -> Void in
guard changeCurrentIndex == true else { return }
oldCell?.label.textColor = .lightGray
newCell?.label.textColor = .black
}
- Swift 版本:5
- Xcode 版本:12.1
- XLPagerTabStrip:9.0.0
有人可以帮我摆脱这个警告信息吗?
【问题讨论】:
-
尝试删除
[weak self],因为您没有在闭包内访问 self。
标签: ios swift xlpagertabstrip