Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于Cell重用的问题 #2

Open
focus-ming opened this issue Apr 28, 2020 · 6 comments
Open

关于Cell重用的问题 #2

focus-ming opened this issue Apr 28, 2020 · 6 comments

Comments

@focus-ming
Copy link

focus-ming commented Apr 28, 2020

想问一下大佬 APP中有些使用场景是同一个cell可能会对应不同的model
但是目前这套模式 cell的viewdata直接定死了cell惟一对应的model类型。导致同样的Cell无法绑定其它类型的model。 不知道大佬有解决方案吗?

@huangboju
Copy link
Owner

你的意思是同一个cell的数据,需要多个model组合起来吗

@focus-ming
Copy link
Author

你的意思是同一个cell的数据,需要多个model组合起来吗

不不 比如有个ButtonCell 在A页面 有个A类型的model ButtonCell 需要通过A model 来设置UI
在B页面也用到了ButtonCell 但是此时Model为B 此时需要通过B model来设置UI 这样的Case怎么处理

@huangboju
Copy link
Owner

哦哦,懂你的意思你,想想为什么我在cell与model之间抽象了一层cellModel,其实你是不是可以抽象一个协议,buttonCell依赖你的协议,然后cellModel去遵循抽象的协议,这样应该就可以解决了吧

@focus-ming
Copy link
Author

哦哦,懂你的意思你,想想为什么我在cell与model之间抽象了一层cellModel,其实你是不是可以抽象一个协议,buttonCell依赖你的协议,然后cellModel去遵循抽象的协议,这样应该就可以解决了吧

明白 我尝试一下 谢谢大佬

@huangboju
Copy link
Owner

哦哦,懂你的意思你,想想为什么我在cell与model之间抽象了一层cellModel,其实你是不是可以抽象一个协议,buttonCell依赖你的协议,然后cellModel去遵循抽象的协议,这样应该就可以解决了吧

明白 我尝试一下 谢谢大佬

不客气,其实你再抽象个协议,你的didselect处理,也能放到cellmodel了,这样就形成了一条链路,UI的数据,事件处理,都再cellModel里面了,VC就起到一个协调作用,VC的代码就会非常干净,整个架构扩展性也会很强

@ios582754
Copy link

哦哦,懂你的意思你,想想为什么我在cell与model之间抽象了一层cellModel,其实你是不是可以抽象一个协议,buttonCell依赖你的协议,然后cellModel去遵循抽象的协议,这样应该就可以解决了吧

明白 我尝试一下 谢谢大佬

你是实现了吗,老哥,能借鉴下吗,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants