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

个人中心demo,swift实现问题 #527

Open
shuaiwang007 opened this issue Dec 20, 2024 · 1 comment
Open

个人中心demo,swift实现问题 #527

shuaiwang007 opened this issue Dec 20, 2024 · 1 comment

Comments

@shuaiwang007
Copy link

image

swift中,self.pagingView.listContainerView无法转换为JXCategoryViewListContainer协议类型,导致self.categoryView.listContainer = listContainer无法执行,因此无法切换联动,swift中应该如何设置呢?

@Sweet01
Copy link

Sweet01 commented Feb 28, 2025

// 1. 定义适配器类
class ListContainerAdapter: NSObject, JXCategoryViewListContainer {
func contentScrollView() -> UIScrollView! {
return containerView?.scrollView ?? UIScrollView()
}
private weak var containerView: JXPagerListContainerView?
init(containerView: JXPagerListContainerView) {
self.containerView = containerView
super.init()
}
func setDefaultSelectedIndex(_ index: Int) {
containerView?.setDefaultSelectedIndex(index)
}
func reloadData() {
containerView?.reloadData()
}
func didClickSelectedItem(at index: Int) {
containerView?.didClickSelectedItem(at: index)
}
}
// 2.创建适配器并关联
let adapter = ListContainerAdapter(containerView: pagerView.listContainerView)
categoryTitleView.listContainer = adapter
这样可以解决Swift遵循OC协议。

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

2 participants