我想通过一个范围到一个名为 a 的函数selector from a timer。具体参考一个cell
这样我就可以更新一些内容UI.
所以我想要这样的东西:
timer = Timer.init(timeInterval: 1.0, target: self, selector: #selector(downloadTimer(cell: cell), userInfo: nil, repeats: true)
Function
func downloadTimer(cell: InnerCollectionCell) {
cell.progressBar.setProgress(downloadProgress, animated: true)
}
虽然我可能有点侄女假设这可以做到?
- - - 编辑 - - -
按照下面的示例,但没有像往常一样从单元格中获得预期结果
let innerCell: InnerCollectionCell = collectionView.dequeueReusableCell(withReuseIdentifier: reuseIdentifierInner, for: indexPath) as! InnerCollectionCell
timer = Timer.init(timeInterval: 1.0, target: self, selector: #selector(downloadTimer(_:)), userInfo: innerCell, repeats: true)
func downloadTimer(_ timer: Timer) {
let cell = timer.userInfo
cell. // no options as expected of a cell
}
![enter image description here](https://i.stack.imgur.com/pYhht.png)
如果数据发送正确,我期望有更多这样的选项:
![enter image description here](https://i.stack.imgur.com/1zIaE.png)
使用用户信息设置计时器
timer = Timer.init(timeInterval: 1.0, target: self, selector: #selector(downloadTimer(cell: cell), userInfo: data, repeats: true)
并获取用户信息如下
func downloadTimer(_ timer: Timer) {
let data = timer.userInfo
}
- - - 编辑 - - -
按照下面的示例,但没有像往常一样从单元格中获得预期结果
let innerCell: InnerCollectionCell = collectionView.dequeueReusableCell(withReuseIdentifier: reuseIdentifierInner, for: indexPath) as! InnerCollectionCell
timer = Timer.init(timeInterval: 1.0, target: self, selector: #selector(downloadTimer(_:)), userInfo: innerCell, repeats: true)
func downloadTimer(_ timer: Timer) {
let cell = timer.userInfo as! InnerCollectionCell
cell. // no options as expected of a cell
}
![enter image description here](https://i.stack.imgur.com/pYhht.png)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)