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

XLPagerTabStrip.ButtonBarView.move() : Crash in ButtonBarView.swift, line 81 #575

Open
rkittinger opened this issue Apr 30, 2018 · 16 comments

Comments

@rkittinger
Copy link

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)
....

@rkittinger
Copy link
Author

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

@hao-li
Copy link

hao-li commented Jun 24, 2018

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

@hyuni
Copy link

hyuni commented Jun 29, 2018

@rkittinger @hao-li check ButtonBarView type. that UICollectionView type.

@ThomGru
Copy link

ThomGru commented Jul 2, 2018

@hyuni what do mean?

@mlb5000
Copy link

mlb5000 commented Aug 8, 2018

@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.

@Yurssoft
Copy link

Yurssoft commented Sep 3, 2018

The same issue, change UIView to UICollectionView and it is fixed

@wakaryry
Copy link

wakaryry commented Oct 8, 2018

When I changed ButtonBarView into UICollectionView, it throw EXC_BAD_ACCESS.
How could I make it?

@gazreese
Copy link

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.

@RowanG1
Copy link

RowanG1 commented Feb 20, 2019

@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 instructions README says UIView specifically??

@dev-myatminsoe
Copy link

Already using UICollectionView and using ButtonBarView class. Still crashing

@yonasputraa
Copy link

Try setting the buttonbarview before super.viewDidLoad()

@sgelves
Copy link

sgelves commented Jul 8, 2019

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

@luiswolf
Copy link

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

@jesster2k10
Copy link

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()]
  }
}

@grantespo
Copy link

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)

siam009 added a commit to siam009/XLPagerTabStrip that referenced this issue May 24, 2022
vjard33 added a commit to Picslo-Corp/XLPagerTabStrip that referenced this issue Dec 5, 2022
@tkhabbab
Copy link

Just Settings buttonbarview style before super.viewDidLoad()

Screenshot 2023-06-29 at 6 46 45 AM

MainasuK added a commit to TwidereProject/XLPagerTabStrip that referenced this issue Jun 6, 2024
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