Skip to content

Commit

Permalink
Fixed bug with checkmark
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyailya committed Mar 14, 2016
1 parent b54beec commit 7393e5c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
3 changes: 1 addition & 2 deletions Demo/Demo/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
//

import UIKit
import BTNavigationDropdownMenu

class ViewController: UIViewController {

Expand All @@ -22,7 +21,7 @@ class ViewController: UIViewController {
self.navigationController?.navigationBar.barTintColor = UIColor(red: 0.0/255.0, green:180/255.0, blue:220/255.0, alpha: 1.0)
self.navigationController?.navigationBar.titleTextAttributes = [NSForegroundColorAttributeName: UIColor.whiteColor()]

menuView = BTNavigationDropdownMenu(navigationController: self.navigationController, title: items.first!, items: items)
menuView = BTNavigationDropdownMenu(navigationController: self.navigationController, title: items[1], items: items)
menuView.cellHeight = 50
menuView.cellBackgroundColor = self.navigationController?.navigationBar.barTintColor
menuView.cellSelectionColor = UIColor(red: 0.0/255.0, green:160.0/255.0, blue:195.0/255.0, alpha: 1.0)
Expand Down
8 changes: 5 additions & 3 deletions Source/BTNavigationDropdownMenu.swift
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ public class BTNavigationDropdownMenu: UIView {
self.init(navigationController: nil, title: title, items: items)
}


public init(navigationController: UINavigationController?, title: String, items: [AnyObject]) {

// Navigation controller
Expand Down Expand Up @@ -250,7 +251,7 @@ public class BTNavigationDropdownMenu: UIView {
self.backgroundView.addGestureRecognizer(backgroundTapRecognizer)

// Init table view
self.tableView = BTTableView(frame: CGRectMake(menuWrapperBounds.origin.x, menuWrapperBounds.origin.y + 0.5, menuWrapperBounds.width, menuWrapperBounds.height + 300), items: items, configuration: self.configuration)
self.tableView = BTTableView(frame: CGRectMake(menuWrapperBounds.origin.x, menuWrapperBounds.origin.y + 0.5, menuWrapperBounds.width, menuWrapperBounds.height + 300), items: items, title: title, configuration: self.configuration)

self.tableView.selectRowAtIndexPathHandler = { (indexPath: Int) -> () in
self.didSelectItemAtIndexHandler!(indexPath: indexPath)
Expand Down Expand Up @@ -459,11 +460,11 @@ class BTTableView: UITableView, UITableViewDelegate, UITableViewDataSource {
fatalError("init(coder:) has not been implemented")
}

init(frame: CGRect, items: [AnyObject], configuration: BTConfiguration) {
init(frame: CGRect, items: [AnyObject], title: String, configuration: BTConfiguration) {
super.init(frame: frame, style: UITableViewStyle.Plain)

self.items = items
self.selectedIndexPath = 0
self.selectedIndexPath = (items as! [String]).indexOf(title)
self.configuration = configuration

// Setup table view
Expand Down Expand Up @@ -498,6 +499,7 @@ class BTTableView: UITableView, UITableViewDelegate, UITableViewDataSource {
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = BTTableViewCell(style: UITableViewCellStyle.Default, reuseIdentifier: "Cell", configuration: self.configuration)
cell.textLabel?.text = self.items[indexPath.row] as? String

cell.checkmarkIcon.hidden = (indexPath.row == selectedIndexPath) ? false : true

return cell
Expand Down

0 comments on commit 7393e5c

Please sign in to comment.