coder-tanjx / jxbanner Goto Github PK
View Code? Open in Web Editor NEW🚀🚀🚀 A super - custom multifunctional framework for banner unlimited rollover diagrams [一个超自定义多功能无限轮播图框架]
License: MIT License
🚀🚀🚀 A super - custom multifunctional framework for banner unlimited rollover diagrams [一个超自定义多功能无限轮播图框架]
License: MIT License
没有找到方法让banner滚动到指定位置
isPagingEnabled(false) and isAutoPlay(true)不兼容
不用复杂的交互
我看框架里面有写RTL的处理,但是,是滑动的时候,页面还是出现了问题,并且pageControl的方向也不对
只需要修改垂直参数,就可以实现了。望支持,谢谢!
JXBannerLayout中设置:scrollDirection = .vertical
JXBaseBanner类中修改:
collectionView.scrollToItem(at: indexPath,
at: .centeredVertically,
animated: animated)
func scrollToIndexPath(_ indexPath: IndexPath, animated: Bool) { }
方法内部调用collectionView滚动方法,在系统版本低的设备上会触发闪退的情况。
断点分析为collectionView未刷新完成,调用scrollToItem导致。
解决办法:
我尝试在滚动之前,判断要求滚动到的index是否合法,且滚动到的位置是否有item,可以解决闪退问题
添加的判断代码如下:
guard collectionView.numberOfItems(inSection: indexPath.section) > indexPath.row, let _ = collectionView.dataSource?.collectionView(collectionView, cellForItemAt: indexPath) else { return }
设置自动后 视频不会播放 不走代理
机型:iPhone Xr 系统版本14.4
JXPageControlScale里updateProgressyy12CoreGraphics7CGFloatVF + 1992 出现crash
libmecab.dylib
MeCab::TokenizerImpl<mecab_node_t, mecab_path_t>::lookup(char const*, char const*) + 340
19
UIKitCore
-[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededCollectingViews:forSecondPass:] + 660
20
CoreAutoLayout
0x0000000199050000 + 66844
21
UIKitCore
-[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededWithViewForVariableChangeNotifications:] + 608
29
QuartzCore
CA::Transaction::commit() + 732
感谢作者的代码贡献
请问一下,
scrollView 模式想打开 isPagingEnabled,
但是需要靠左显示,不需要居中显示,应该如何设置呢?
如题
When reload data, we usually want to set an first display index.
seems like your code does not include that feature
带缩放的轮播图(JXBannerTransformLinear),手动拖拽超过一半位置后松手正常应该滚动到下一个cell,而目前还是滚动到当前cell
Thread 1: "Attempted to scroll the collection view to an out-of-bounds item (1000) when there are only 1 items in section 0. Collection view: <UICollectionView: 0x14b009e00; frame = (0 0; 362 655); clipsToBounds = YES; autoresize = W+H; gestureRecognizers = <NSArray: 0x2821c6c70>; layer = <CAGradientLayer: 0x283da90a0>; contentOffset: {0, 0}; contentSize: {362, 117.5}; adjustedContentInset: {0, 0, 0, 0}; layout: <JXBanner.JXBannerLayout: 0x14aa2c130>; dataSource: <JXBanner.JXBanner: 0x14aa2bd10; frame = (10 47.5; 362 655); tag = 10; layer = <CAGradientLayer: 0x283da8f00>>>."
//MARK: - override
override public func layoutSubviews() {
super.layoutSubviews()
if let itemSize = layout.params?.itemSize {
let x = (bounds.size.width - itemSize.width) * 0.5
let y = (bounds.size.height - itemSize.height) * 0.5
placeholderImgView.frame = CGRect(x: x, y: y, width: itemSize.width, height: itemSize.height)
}else {
placeholderImgView.frame = bounds
layout.params = layout.params
}
if pageCount > 0 {
scrollToIndexPath(currentIndexPath, animated: false)---------> 这里
}
}
JYPageControlScale.swift
if isShowCorner {
if leftWidth > leftHeight {
leftLayer.cornerRadius = leftHeight0.5
}else {
leftLayer.cornerRadius = leftWidth0.5
}
if rightWidth > rightHeight {
rightLayer.cornerRadius = rightHeight0.5
}else {
rightLayer.cornerRadius = rightWidth0.5
}
}
JYPageControlScale.swift
if isShowCorner {
if leftWidth > leftHeight {
leftLayer.cornerRadius = leftHeight*0.5
}else {
leftLayer.cornerRadius = leftWidth*0.5
}
if rightWidth > rightHeight {
rightLayer.cornerRadius = rightHeight*0.5
}else {
rightLayer.cornerRadius = rightWidth*0.5
}
}
JXBanner支持SwiftUI吗?有没有SwiftUI的版本呢?谢谢!
滑动的时候,动画很生硬,跟卡一下似得
在ios12上,轮播图只有一张的时候
崩溃在JXBanner.swift 底184行代码
after pod JXBanner to my code , but i can't change the banner index manually in my code.
eg.
lazy var banner: JXBanner = {
let banner = JXBanner()
banner.backgroundColor = UIColor.clear
banner.delegate = self
banner.dataSource = self
return banner
}()
==========================
self.banner.setCurrentIndex(1) //it is coun't work
may i access property currentIndexPath to change?
thank you.
如题
机型: iPhone 6
系统:11.2.1,12.5.5等
复现:基本功能使用,JXBanner(frame:), JXBannerCell。当只有1张图片时,cell向左偏移一半,仅显示右半部分。
多张图片则无此现象,其他机型也无此现象
Cell的Size会自适应图片尺寸,itemSize无效。是我设置问题吗?
避免重复scrollToItem
fix reuse scrollToItem: to mask the bug of inaccurate scroll position
collectionView.scrollToItem(at: indexPath,
at: scrollPosition,
animated: animated)
collectionView.scrollToItem(at: indexPath,
at: scrollPosition,
animated: animated)
func scrollToIndexPath(
_ indexPath: IndexPath, animated: Bool) {
if params.isPagingEnabled {
let itemCount = collectionView.numberOfItems(inSection: indexPath.section)
let itemWidth = layout.itemSize.width
let itemHeight = layout.itemSize.height
if layout.params?.scrollDirection == .vertical {
let sectionSpacing = layout.sectionInset.left + layout.sectionInset.right
let itemSpacing = layout.minimumLineSpacing
let sectionHeight = CGFloat(indexPath.section) * (itemHeight + itemSpacing) * CGFloat(itemCount)
let verticalOffset = sectionHeight + sectionSpacing / 2 + (itemHeight + itemSpacing) * CGFloat(indexPath.item) - collectionView.bounds.height / 2 + itemHeight / 2
let offset = CGPoint(x: 0, y: verticalOffset)
collectionView.setContentOffset(offset, animated: animated)
}else {
let sectionSpacing = layout.sectionInset.top + layout.sectionInset.bottom
let itemSpacing = layout.minimumInteritemSpacing
let sectionWidth = CGFloat(indexPath.section) * (itemWidth + itemSpacing) * CGFloat(itemCount)
let horizontalOffset = sectionWidth + sectionSpacing / 2 + (itemWidth + itemSpacing) * CGFloat(indexPath.item) - collectionView.bounds.width / 2 + itemWidth / 2
let offset = CGPoint(x: horizontalOffset, y: 0)
collectionView.setContentOffset(offset, animated: animated)
}
}
}
func jxBanner(pageControl banner: JXBannerType, numberOfPages: Int, coverView: UIView, builder: JXBannerPageControlBuilder) -> JXBannerPageControlBuilder { let pageControl = JXPageControlChameleon() pageControl.contentMode = .right let size = CGSize(width: 3, height: 3) pageControl.activeSize = size pageControl.indicatorSize = size pageControl.inactiveSize = size pageControl.activeColor = UIColor(red: 16, green: 142, blue: 233)! pageControl.inactiveColor = .white pageControl.columnSpacing = 6 pageControl.isAnimation = true builder.pageControl = pageControl builder.layout = { pageControl.snp.makeConstraints { (maker) in maker.left.right.equalTo(coverView).inset(10).priority(750) maker.bottom.equalTo(coverView.snp.bottom).inset(2) maker.height.equalTo(20) } } return builder }
设置banner 宽高为屏幕宽高,然后itemSize也设置为屏幕宽高,设置
、、、
tempCell.imageView.contentMode = .scaleAspectFill
、、、
图片两边会缺一小块
Hi TanJX,
I am trying to add video instead of image into the cell but have a problem with func collectionView(_ collectionView: UICollectionView, willDisplay cell: UICollectionViewCell, forItemAt indexPath: IndexPath).
I cannot run this function. I added this function to JXBanner, JXBannerDelegate. I am trying to run video when the related cell visible.
Can you help me plz
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.