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

Crash on init #13

Closed
DennisDreissen opened this issue Sep 12, 2015 · 7 comments
Closed

Crash on init #13

DennisDreissen opened this issue Sep 12, 2015 · 7 comments

Comments

@DennisDreissen
Copy link

I can't get the drop down menu to work, it keeps crashing as soon as it starts loading. It crashes at the point where it creates the frame in the "init" function. I am using Xcode 6.4 with iOS 8.

Here's my code:

import UIKit
import CVCalendar
import BTNavigationDropdownMenu

class RosterViewController: UIViewController, UITableViewDelegate, UITableViewDataSource, UITextFieldDelegate {

@IBOutlet weak var menuButton:UIBarButtonItem!
@IBOutlet weak var tableView: UITableView!
@IBOutlet weak var calendarView: CVCalendarView!
@IBOutlet weak var menuView: CVCalendarMenuView!

var menuViewNav: BTNavigationDropdownMenu!

override func viewDidLoad() {
    super.viewDidLoad()

    tableView.delegate = self
    tableView.dataSource = self
    tableView.tableFooterView = UIView()

    let items = ["Most Popular", "Latest", "Trending", "Nearest", "Top Picks"]
    menuViewNav = BTNavigationDropdownMenu(title: "Hey", items: items)
    menuViewNav.didSelectItemAtIndexHandler = {(indexPath: Int) -> () in
        print("Did select item at index: \(indexPath)")
    }
    self.navigationItem.titleView = menuViewNav

    if self.revealViewController() != nil {
        menuButton.target = self.revealViewController()
        menuButton.action = "revealToggle:"
        self.view.addGestureRecognizer(self.revealViewController().panGestureRecognizer())
    }
}
@DennisDreissen
Copy link
Author

I fixed it by setting the navigationController manually. I'm now sending the navigationController together with the title and the items.

BTNavigationDropdownMenu(title: "Hey", items: items, nav: navigationController!)

Not sure if this is the proper way to do it, but at least it works.

@Magrider
Copy link

Same issue, crashing on // Set frame
let frame = CGRectMake(0, 0, titleSize.width + (self.configuration.arrowPadding + self.configuration.arrowImage.size.width)*2, (self.navigationController?.navigationBar.frame.height)!)

show thread 1 exc_bad_instruction (code=exc_i386_invop subcode=0x0)

The navigationController is nil.

@PhamBaTho
Copy link
Owner

Hi, please check this commit. I fixed bug relating to the availability of navigation controller. I also updated to CocoaPods for this fix (version 0.1.8).

@stevesarkisian-tribpub
Copy link

I'm getting same exact issue, The navigationController is nil. Using CocoaPods version 0.1.8.

@whitefoxy
Copy link

The same error

@liberty4me
Copy link

The top viewcontroller in my app is a UITabBarController instead of UINavigationController, so I think it should be able to set by programmer.

@PhamBaTho
Copy link
Owner

@liberty4me 👍

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

6 participants