We are experiencing crashes with Version 8.0.0 in ButtonBarView.swift, line 81:
XLPagerTabStrip.ButtonBarView.move(fromIndex: Swift.Int, toIndex: Swift.Int, progressPercentage: CoreGraphics.CGFloat, pa.....
Incident Identifier: CE2A8647-3EFF-4CCF-8A50-B32F6FF43288
CrashReporter Key: D2F3275C-B5EA-4528-91BD-7C86CC9DD08F
Hardware Model: iPhone9,3
Code Type: ARM-64
Parent Process: ??? [1]
Date/Time: 2018-04-26T23:39:50Z
Launch Time: 2018-04-26T22:59:52Z
OS Version: iPhone OS 11.3 (15E216)
Report Version: 104
Exception Type: SIGSEGV
Exception Codes: SEGV_ACCERR at 0xfffffffffffffff8
Crashed Thread: 0
Application Specific Information:
Selector name found in current argument registers: indexAtPosition:
Thread 0 Crashed:
0 UIKit 0x000000018f1cda9c -[UICollectionViewData layoutAttributesForItemAtIndexPath:] + 248
1 UIKit 0x000000018f1d58a4 -[UICollectionView layoutAttributesForItemAtIndexPath:] + 144
2 XLPagerTabStrip 0x0000000102970da8 XLPagerTabStrip.ButtonBarView.move(fromIndex: Swift.Int, toIndex: Swift.Int, progressPercentage: CoreGraphics.CGFloat, pagerScroll: XLPagerTabStrip.PagerScroll) -> () (ButtonBarView.swift:81)
3 XLPagerTabStrip 0x0000000102967d5c XLPagerTabStrip.ButtonBarPagerTabStripViewController.updateIndicator(for: XLPagerTabStrip.PagerTabStripViewController, fromIndex: Swift.Int, toIndex: Swift.Int, withProgressPercentage: CoreGraphics.CGFloat, indexWasChanged: Swift.Bool) -> () (ButtonBarPagerTabStripViewController.swift:247)
4 XLPagerTabStrip 0x000000010296c88c protocol witness for XLPagerTabStrip.PagerTabStripIsProgressiveDelegate.updateIndicator(for: XLPagerTabStrip.PagerTabStripViewController, fromIndex: Swift.Int, toIndex: Swift.Int, withProgressPercentage: CoreGraphics.CGFloat, indexWasChanged: Swift.Bool) -> () in conformance XLPagerTabStrip.ButtonBarPagerTabStripViewController : XLPagerTabStrip.PagerTabStripIsProgressiveDelegate in XLPagerTabStrip (ButtonBarPagerTabStripViewController.swift:0)
5 XLPagerTabStrip 0x00000001029800d8 XLPagerTabStrip.PagerTabStripViewController.updateContent() -> () (PagerTabStripViewController.swift:277)
6 XLPagerTabStrip 0x000000010297d7dc XLPagerTabStrip.PagerTabStripViewController.updateIfNeeded() -> () (PagerTabStripViewController.swift:189)
7 XLPagerTabStrip 0x0000000102983b48 XLPagerTabStrip.PagerTabStripViewController.viewDidLayoutSubviews() -> () (PagerTabStripViewController.swift:144)
8 XLPagerTabStrip 0x0000000102983b80 @objc XLPagerTabStrip.PagerTabStripViewController.viewDidLayoutSubviews() -> () (PagerTabStripViewController.swift:0)
9 XLPagerTabStrip 0x00000001029669ec XLPagerTabStrip.ButtonBarPagerTabStripViewController.viewDidLayoutSubviews() -> () (ButtonBarPagerTabStripViewController.swift:177)
10 XLPagerTabStrip 0x0000000102966e84 @objc XLPagerTabStrip.ButtonBarPagerTabStripViewController.viewDidLayoutSubviews() -> () (ButtonBarPagerTabStripViewController.swift:0)
11 UIKit 0x000000018f07b8e4 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1788
12 QuartzCore 0x000000018961d25c -[CALayer layoutSublayers] + 180
13 QuartzCore 0x00000001896213ec CA::Layer::layout_if_needed(CA::Transaction*) + 320
14 UIKit 0x000000018f093c70 -[UIView(Hierarchy) layoutBelowIfNeeded] + 544
15 UIKit 0x000000018f04850c -[UIView(Geometry) setFrame:] + 656
16 UIKit 0x000000018f51b2b0 -[UIViewController autoresizeArchivedView] + 108
17 UIKit 0x000000018f51ac0c -[UIViewController _loadViewFromNibNamed:bundle:] + 672
18 UIKit 0x000000018f15e0f0 -[UIViewController loadView] + 172
19 UIKit 0x000000018f082b90 -[UIViewController loadViewIfRequired] + 168
20 UIKit 0x000000018f082acc -[UIViewController view] + 24
21 UIKit 0x000000018fa597c8 -[UIPageViewController _setViewControllers:withScrollInDirection:animated:completion:] + 516
22 UIKit 0x000000018fa59a7c -[UIPageViewController setViewControllers:direction:animated:completion:] + 264
23 test 0x0000000100cdc8a8 OurApp.MainPagedViewController.viewDidLoad() -> () (MainPagedViewController.swift:86)
....
EXC_BAD_ACCESS happens in open func move(fromIndex: Int, toIndex: Int, progressPercentage: CGFloat, pagerScroll: PagerScroll)
--> let fromFrame = layoutAttributesForItem(at: IndexPath(item: fromIndex, section: 0))!.frame
We are experiencing crashes with Version 8.0.1 in ButtonBarView.swift, line 81:
Thread 1: Fatal error: Unexpectedly found nil while unwrapping an Optional value
--> let fromFrame = layoutAttributesForItem(at: IndexPath(item: fromIndex, section: 0))!.frame
@rkittinger @hao-li check ButtonBarView type. that UICollectionView type.
@hyuni what do mean?
@rkittinger @hao-li @ThomGru Make sure that when you added your ButtonBarView to your Storyboard that you added a UICollectionView and not a plain UIView. Even if you set the UIView's class type to ButtonBarView it will still have this problem.
The same issue, change UIView to UICollectionView and it is fixed
When I changed ButtonBarView into UICollectionView, it throw EXC_BAD_ACCESS.
How could I make it?
Also ran into this problem and fixed it by making the control a UICollectionView before changing the class to ButtonBarView in Interface Builder.
This could be a lot more obvious by changing the wording in the README.md file.
@rkittinger @hao-li @ThomGru Make sure that when you added your ButtonBarView to your Storyboard that you added a UICollectionView and not a plain UIView. Even if you set the UIView's class type to
ButtonBarViewit will still have this problem.
The instructions README says UIView specifically??
Already using UICollectionView and using ButtonBarView class. Still crashing
Try setting the buttonbarview before super.viewDidLoad()
Settings buttonbarview style before super.viewDidLoad() fixed it. https://medium.com/michaeladeyeri/how-to-implement-android-like-tab-layouts-in-ios-using-swift-3-578516c3aa9
Still getting the error with version 9.0 and setting barbuttonview style before super.viewDidLoad()
ButtonBarView.swift - Line 81
specialized ButtonBarView.move(fromIndex:toIndex:progressPercentage:pagerScroll:) + 81
If you're setting up programatically, make sure to add your subviews and constraints before super.viewDidLoad() like so:
import UIKit
import XLPagerTabStrip
class InboxViewController: ButtonBarPagerTabStripViewController, InboxViewProtocol {
var presenter: InboxPresenterProtocol?
lazy var scrollView = UIScrollView()
lazy var barView: ButtonBarView = {
let layout = UICollectionViewFlowLayout()
let frame = CGRect(x: 0, y: 0, width: view.frame.width, height: 64)
let collectionView = ButtonBarView(frame: frame, collectionViewLayout: layout)
collectionView.backgroundColor = .red
return collectionView
}()
override func viewDidLoad() {
view.addSubview(scrollView)
containerView = scrollView
scrollView.snp.makeConstraints { $0.edges.equalToSuperview() }
view.addSubview(barView)
buttonBarView = barView
barView.snp.makeConstraints {
$0.top.equalToSuperview()
$0.left.equalToSuperview()
$0.right.equalToSuperview()
$0.height.equalTo(64)
}
super.viewDidLoad()
}
override func viewControllers(for pagerTabStripController: PagerTabStripViewController) -> [UIViewController] {
return [InboxRouter.createBuyerInbox(), InboxRouter.createSellerInbox()]
}
}
This error occured for me when I used a
UIView.animate(withDuration: 0.0, animations: {
///....
self.view.layoutIfNeeded()
})
before super.viewDidLoad
so, make sure you are not doing anythin heavy before super.load (ex DispatchQueue.main.async)
Most helpful comment
@rkittinger @hao-li @ThomGru Make sure that when you added your ButtonBarView to your Storyboard that you added a UICollectionView and not a plain UIView. Even if you set the UIView's class type to
ButtonBarViewit will still have this problem.