Giter Club home page Giter Club logo

dropdownmenukit's Introduction

DropDownMenuKit

Build Status Platforms iOS Language Swift 5 License MIT

DropDownMenuKit is a custom UIKit control to show a menu attached to the navigation bar or toolbar. The menu appears with a sliding animation and can be deeply customized. For example, with icons, embedded controls, or a checkmark to denote a selected row among multiple menu cells.

The control is made up of three parts:

  • DropDownMenu: the menu itself, a UIView subclass that contains a UITableView presenting one or more DropDownMenuCell(s)
  • DropDownMenuCell: a menu entry, implemented as a UITableViewCell subclass
  • DropDownMenuTitleView: an optional title view to toggle the menu, which is usually put in the navigation bar and acts as a disclosure indicator

Screenshot

Screenshot

To see in action, take a look at the very beginning of Placeboard demo video.

Compatibility

DropDownMenuKit requires at least Xcode 10.2 (introducing Swift 5) and supports iOS 11 and higher.

For versions compatible with Swift 3 and 4, see branches named swift-3/4.x.

For now, the code base remains compatible with older iOS versions (8 or higher), but these older versions are not supported anymore.

Installation

Carthage

Add the following line to your Cartfile, run carthage update to build the framework and drag the built DropDownMenuKit.framework into your Xcode project.

github "qmathe/DropDownMenuKit"

CocoaPods

Add the following lines to your Podfile and run pod install with CocoaPods 1.9 or newer.

pod "DropDownMenuKit"

Manually

If you don't use Carthage or CocoaPods, it's possible to drag the built framework or embed the source files into your project.

Framework

Build DropDownMenuKit framework and drop it into your Xcode project.

Files

Drop DropDownMenu.swift, DropDownMenuCell.swift, DropDownTitleView.swift and DropDownMenuKit.xcassets into your Xcode project.

App Extension Usage

Build Settings

Add -DAPP_EXTENSION to DropDownMenuKit > Build Settings > Other Swift Flags.

Restrictions

  • DropDownMenuCell.menuAction must take a single argument
  • DropDownMenuCell.menuTarget must not be nil

dropdownmenukit's People

Contributors

grifas avatar ngheungyu avatar qmathe avatar rico237 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dropdownmenukit's Issues

Use in Objective-C code?

I have a project which combines both swift and objective-c code. How to import it into objective-C code correctly - it can't find the path?

Menu and container not released

Variable 'container' in DropDownMenu.swift (line 23) is strong reference, therefore when container is removed from view hierarhy it maintains referenced by DropDownMenu and can not be destroyed.
Solution: make container weak reference and perform necessary checks in methods show, hide and visibleContentOffset.didSet

Table view not filled

Hi,
I fetch my data asynchronously and I fill the menuCells once I have it. My issue is the table view is not filled or may be is not displayed.

Have you a solution ?

Drop Down Menu does not work in a popup

I have a issue when using the drop down menu in pop up and choosing a cell: I get the following error:

screen shot 2017-08-24 at 4 10 31 pm

Could you please provide a solution for it? Thank you in advance

Broken cocoapods

You specified "swift 4.2" in podspec but in the same time by default the pod install command ignores master and downloads branch for "4.1"

Swift 3

it'd be cool to have a swift 3 version, if you have any interest to create a branch i would like to help with that.

Check for empty cells is missing from pod install version in DropDownMenu class

Hello,

Thanks for nice lib.
Yesterday I have faced following issue.
In the GitHub version in master branch I have noticed that in DropDownMenu.swift file line 156 there is if statement for checking empty cell case before scrolling tableview:

	contentView.frame.size.height = menuView.frame.height

	// Reset scroll view content offset after rotation
	if menuView.visibleCells.isEmpty {
			return
		}
	menuView.scrollToRow(at: IndexPath(row: 0, section: 0), at: .top, animated: false)

But when I have pod install on my project I notice that this statement is missing from source code and it cause exception at runtime when DropDownMenu does not have any cell.

Could you please help me get last version via pod install?

My podfile is:
pod 'DropDownMenuKit'

Error retrieving icon from bundle

Hi,

in some cases this pod can raise an error (and cause a crash) when retrieving an icon from the xcassets file.

This happens when you subclass DropDownTitleView, therefore the pod can't retrieve the bundle in which the icon is supposed to be and finally crashes trying to unwrap a nil value.

The fix is very easy: DigitalGoal-Ltd@e98532c

spam on DropDownTitleView

When i quickly multiple tap DropDownTitleView it seem to create a thing. where u need to multiple tap in order to get it to drop down?

hide when choose a cell

Hi,

Where it's best to close the DropDownMenu when you have selected a item Cell? Now you have to select the titleView or the Menubackground

issue when working with MBProgressHUD

on cell.menuAction selector like this:
func choose(_ sender: AnyObject) {
titleView.toggleMenu()
showHud();
hideHud();
}
and the dropMenu animation will be strange.

Pod Build fails with current version of Swift

Integrated the framework via Cocoapods. When I build my project this framework lists 20 or so errors. Would love to use this library, could you guys take a look and build it with the latest Xcode and Swift, and update the pod spec to use the latest version? Thanks. @qmathe @grifas

The Dropdownmenu won't scroll when too many items

I'm using this array with 19 items on it, some items are then listed outside of the iphone screen and the menu don't scroll so users can't reach the 19th elements of my array ...

["Alimentaire","Artisanat","Bien-être","Décoration","E-commerce","Distribution","Hôtellerie","Immobilier","Informatique","Métallurgie","Médical","Nautisme","Paramédical","Restauration","Sécurité","Textile","Tourisme","Transport","Urbanisme"]

The code I used to dynamically load array into your menu from your demo project

`func prepareNavigationBarMenu(_ currentChoice: String) {
navigationBarMenu = DropDownMenu(frame: view.bounds)
navigationBarMenu.delegate = self

	let toutesCat = ["Alimentaire","Artisanat","Bien-être","Décoration","E-commerce","Distribution","Hôtellerie","Immobilier","Informatique","Métallurgie","Médical","Nautisme","Paramédical","Restauration","Sécurité","Textile","Tourisme","Transport","Urbanisme"]
    var catCells : Array<DropDownMenuCell>
    catCells = []
    
    for string in toutesCat  {
        
        let cell = DropDownMenuCell()
        cell.textLabel!.text = string
        cell.menuAction = #selector(ViewController.choose(_:))
        cell.menuTarget = self
        if currentChoice == cell.textLabel!.text {
            cell.accessoryType = .checkmark
        }
        
        catCells.append(cell)
    }
    
    navigationBarMenu.menuCells = catCells
    navigationBarMenu.selectMenuCell(catCells.first!)
	
	// If we set the container to the controller view, the value must be set
	// on the hidden content offset (not the visible one)
	navigationBarMenu.visibleContentOffset =
		navigationController!.navigationBar.frame.size.height + statusBarHeight()

	// For a simple gray overlay in background
	navigationBarMenu.backgroundView = UIView(frame: navigationBarMenu.bounds)
	navigationBarMenu.backgroundView!.backgroundColor = UIColor.black
	navigationBarMenu.backgroundAlpha = 0.7
}`

Screenshot :

simulator screen shot on iPhone 7+

DropDownMenu Title is overlapping

screen shot 2017-05-30 at 5 32 24 pm

I am using your framework. I have an issue though. My drop down menu title is overlapping with the right bar buttons. How to solve this issue?

Inheritance is forbidden

required public init?(coder aDecoder: NSCoder) {
	    fatalError("init(coder:) has not been implemented")
	}

wtf? I want to create a cell with xib file but I can't because of this useless code

Creating Sections

Hi

Just wondering if it is possible to create sections with section headers like in a UITableView?

Thanks

Title view collapses on the size of the first item.

Hello, I've got an issue with the DropDownTitleView, it seems to fix it's size to the first assigned text.

Even when constructing the view with a way to large frame I run into the same issue:

DropDownTitleView(frame: CGRect(x: 0, y: 0, width: 400, height: 40))

Images say more than words:

Do you have a recommendation how to solve this issue?

And a big thank you for the work you have put into this UI component.

Default selecting a row.

Don't know whether this is related to the repository itself, however i believe that this feature would be useful.

i've tried with following code, but does not seem to work.

override func viewWillAppear(_ animated: Bool) {
    super.viewWillAppear(animated)

    let rowToSelect = IndexPath.init(row: 0, section: 0)

    navigationBarMenu.menuView.selectRow(at: rowToSelect, animated: false, scrollPosition: .none)

    // Calling manually to the delegate method
    navigationBarMenu.tableView(navigationBarMenu.menuView, didSelectRowAt: rowToSelect)
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.