GithubHelp home page GithubHelp logo

12207480 / dopdropdownmenu-enhanced Goto Github PK

View Code? Open in Web Editor NEW
1.7K 50.0 361.0 435 KB

DOPDropDownMenu 添加双列表 优化版 新增图片支持(double tableView, The optimization version ,new add image,detailText)

License: MIT License

Objective-C 98.39% Ruby 1.61%
dopdropdownmenu objective-c menu dropdown

dopdropdownmenu-enhanced's Introduction

DOPDropDownMenu-Enhanced

New Update:
support cell image 新增cell 图片 支持, 新增 detailText

DOPDropDownMenu 添加双列表 优化版 (double tableView, The optimization version )

首先 感谢 DOPDropDownMenu 作者的无私奉献和允许, https://github.com/dopcn/DOPDropDownMenu

我在此基础上美化来了界面,添加了双列表的应用,优化了代码,增强了稳定性,希望大家喜欢

First, I would like to thank the author of the DOPDropDownMenu for their selfless dedication.

This enhanced version includes beautiful improvements to the interface, double tableview capability, optimized code, and improved stability. Enjoy!

CocoaPods

pod 'DOPDropDownMenu-Enhanced', '~> 1.0.0'

应用截图

image image

用法

#pragma mark - data source protocol
@class DOPDropDownMenu;

@protocol DOPDropDownMenuDataSource <NSObject>

@required

/**
 *  返回 menu 第column列有多少行
 */
- (NSInteger)menu:(DOPDropDownMenu *)menu numberOfRowsInColumn:(NSInteger)column;

/**
 *  返回 menu 第column列 每行title
 */
- (NSString *)menu:(DOPDropDownMenu *)menu titleForRowAtIndexPath:(DOPIndexPath *)indexPath;

@optional
/**
 *  返回 menu 有多少列 ,默认1列
 */
- (NSInteger)numberOfColumnsInMenu:(DOPDropDownMenu *)menu;

// 新增  返回 menu 第column列 每行image
- (NSString *)menu:(DOPDropDownMenu *)menu imageNameForRowAtIndexPath:(DOPIndexPath *)indexPath;

// 新增 detailText ,right text
- (NSString *)menu:(DOPDropDownMenu *)menu detailTextForRowAtIndexPath:(DOPIndexPath *)indexPath;

/** 新增
 *  当有column列 row 行 返回有多少个item ,如果>0,说明有二级列表 ,=0 没有二级列表
 *  如果都没有可以不实现该协议
 */
- (NSInteger)menu:(DOPDropDownMenu *)menu numberOfItemsInRow:(NSInteger)row column:(NSInteger)column;

/** 新增
 *  当有column列 row 行 item项 title
 *  如果都没有可以不实现该协议
 */
- (NSString *)menu:(DOPDropDownMenu *)menu titleForItemsInRowAtIndexPath:(DOPIndexPath *)indexPath;

// 新增 当有column列 row 行 item项 image
- (NSString *)menu:(DOPDropDownMenu *)menu imageNameForItemsInRowAtIndexPath:(DOPIndexPath *)indexPath;

// 新增
- (NSString *)menu:(DOPDropDownMenu *)menu detailTextForItemsInRowAtIndexPath:(DOPIndexPath *)indexPath;

@end

#pragma mark - delegate
@protocol DOPDropDownMenuDelegate <NSObject>
@optional
/**
 *  点击代理,点击了第column 第row 或者item项,如果 item >=0
 */
- (void)menu:(DOPDropDownMenu *)menu didSelectRowAtIndexPath:(DOPIndexPath *)indexPath;
@end

dopdropdownmenu-enhanced's People

Contributors

12207480 avatar bluesky0109 avatar icloudsun avatar jayhe avatar jeffreyjackson avatar lawrencehan avatar z563721 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  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

dopdropdownmenu-enhanced's Issues

关于左右列表的高度的问题

NSInteger num = [_leftTableView numberOfRowsInSection:0] >[_rightTableView numberOfRowsInSection:0]?[_leftTableView numberOfRowsInSection:0]:[_rightTableView numberOfRowsInSection:0];
这样写会不会更合理一些???
比如左边只有一行,右边有10行的情况。

第二个问题
menu每一列的初始title 可不可以不是第一个cell的title而是自定义,选中后再呈现cell的title

bugs: isClickHaveItemValid is always zero even i have only one lefttableview

isClickHaveItemValid is always zero even i have only one lefttableview

 BOOL haveItem = [self confiMenuWithSelectRow:indexPath.row];
        BOOL isClickHaveItemValid = self.isClickHaveItemValid ? YES : haveItem;


        if (isClickHaveItemValid && _delegate && [_delegate respondsToSelector:@selector(menu:didSelectRowAtIndexPath:)]) {
            [self.delegate menu:self didSelectRowAtIndexPath:[DOPIndexPath indexPathWithCol:_currentSelectedMenudIndex row:indexPath.row]];

关于选择后原始layer没有移除的问题

我这里手动把bglayer的颜色跟self.backgourndColor挂钩,原来是准备把背后的东西显示出来,
然而发现,当选择tableview的任何一个row之后
textLayer确实更新了,但是旧的文字却没有移除掉

和MJRefresh一起用产生冲突

如图, 在使用MJRefresh的下拉刷新时, 如果MJRefresh的下拉刷新菊花还在转, 这个时候同时去点击DOPDropDownMenu, 会使整个DOPDropDownMenu下降某一高度.

必现的事情

双列菜单有异常

如题,如果有一个双列菜单,当leftTableView中的某个cell和rightTableView的某个cell相同时,点击左边cell,右边那个cell会默认选中。比如区县菜单,点选左边cell崇明,其中的右边cell崇明会默认选中。

你好,有一个想法...

我试着改你的代码 添加了一个代理方法

  • (void)menu:(DOPDropDownMenu *)menu dwx_justTapTopMenu:(NSInteger)topMenuIndex selected:(BOOL)selected;
    就是在下面方法中添加了只点击了每个coloum标题时响应事件
  • (void)menuTapped:(UITapGestureRecognizer *)paramSender {
    //...
    if ([self.delegate respondsToSelector:@selector(menu:dwx_justTapTopMenu:selected:)]) {
    [self.delegate menu:self dwx_justTapTopMenu:tapIndex selected:_show];
    }
    }
    我觉得这样修改不是很优雅.你能进一步修改一下吗?
    还有一个问题,你能把每一个indexPath的deselect方法放出来吗? 因为我这刚才添加的方法,响应了之后,做完相关操作无法取消选中~

Menu的位置

尝试将menu放置在navigationBar上,但是无法显示。如何能够正确显示在navigationBar的正中间?

sometimes the menu column title doesn't get updated

I almost spent a whole morning found out the solution to this problem, just add ceil(size.width), everything works well.

- (void)animateTitle:(CATextLayer *)title show:(BOOL)show complete:(void(^)())complete {
    CGSize size = [self calculateTitleSizeWithString:title.string];
    CGFloat sizeWidth = (size.width < (self.frame.size.width / _numOfMenu) - 25) ? size.width : self.frame.size.width / _numOfMenu - 25;
    title.bounds = CGRectMake(0, 0, ceil(sizeWidth), size.height);
    if (!show) {
        title.foregroundColor = _textColor.CGColor;
    } else {
        title.foregroundColor = _textSelectedColor.CGColor;
    }
    complete();
}


关于灵活设置每列选项

hi..谢谢你提供的控件,能否增加一些方法,用于方便的设置每一列菜单的选中项,或者随时可以重置某几列菜单为默认选项呢。比如,我一个三列菜单,选了某一列下的一个子项,我希望把其他列的菜单还原成默认值。谢谢。

代码优化建议 以及功能拓展

阁下的代码动画结束逻辑的 complete 全都放在的代码的末尾执行, 我认为这样是不对的
例如:

[self animateIndicator:indicator Forward:forward complete:^{
        [self animateTitle:title show:forward complete:^{
            [self animateBackGroundView:background show:forward complete:^{
                [self animateTableView:tableView show:forward complete:^{
                }];
            }];
        }];
    }];
    
    complete();

应该改为

[self animateIndicator:indicator Forward:forward complete:^{
        [self animateTitle:title show:forward complete:^{
            [self animateBackGroundView:background show:forward complete:^{
                [self animateTableView:tableView show:forward complete:^{
                        complete();
                }];
            }];
        }];
    }];
  

这样保证调用该方法时的 complete 是在所有动画完成时才调用的

另外几个建议
手势操作 例如 展开和收起 增加代码直接调用接口

- (void)menuTappedWithIndex:(NSInteger)tapIndex;  //通过传入 index 展开列表  代码引用
 -(void)menuTapped:(UITapGestureRecognizer *)paramSender

- (void)shrinkMenu;  //收起  代码引用
- (void)backgroundTapped:(UITapGestureRecognizer *)paramSender

感谢阁下提供这么优秀的代码 谢谢

每个菜单首次点开后默认选中的问题

您好,发现没设置menu 的defaultIndexPath,然后点开每个菜单,还是会默认选中第一项
然后我是需要设置哪个值,来让第一次进来,每个菜单点开是都默认是没有选择的效果呢?

swift

swift怎么用这个?谢谢 我是新手

很不错。期待更新3列风格

我自己项目是3列的。自己写了一个项目里面用,不过没有开源出来,作者维护很久了,可以做个3列的,增加场景覆盖范围

我开始手动加入了DOPropDownMene,在用cocoapods 导入后报lonker错

uplicate symbol OBJC_IVAR$_DOPDropDownMenu._numOfMenu in:
/Users/youpude/Library/Developer/Xcode/DerivedData/agriculturalApp-ebtktqjqltyjeegekhyqrvkfgmhp/Build/Intermediates/agriculturalApp.build/Debug-iphonesimulator/agriculturalApp.build/Objects-normal/x86_64/DOPDropDownMenu.o
/Users/youpude/Library/Developer/Xcode/DerivedData/agriculturalApp-ebtktqjqltyjeegekhyqrvkfgmhp/Build/Products/Debug-iphonesimulator/libDOPDropDownMenu-Enhanced.a(DOPDropDownMenu.o)
duplicate symbol OBJC_IVAR$_DOPDropDownMenu._indicators in:
/Users/youpude/Library/Developer/Xcode/DerivedData/agriculturalApp-ebtktqjqltyjeegekhyqrvkfgmhp/Build/Intermediates/agriculturalApp.build/Debug-iphonesimulator/agriculturalApp.build/Objects-normal/x86_64/DOPDropDownMenu.o
/Users/youpude/Library/Developer/Xcode/DerivedData/agriculturalApp-ebtktqjqltyjeegekhyqrvkfgmhp/Build/Products/Debug-iphonesimulator/libDOPDropDownMenu-Enhanced.a(DOPDropDownMenu.o)
duplicate symbol OBJC_IVAR$_DOPDropDownMenu._bgLayers in:
/Users/youpude/Library/Developer/Xcode/DerivedData/agriculturalApp-ebtktqjqltyjeegekhyqrvkfgmhp/Build/Intermediates/agriculturalApp.build/Debug-iphonesimulator/agriculturalApp.build/Objects-normal/x86_64/DOPDropDownMenu.o
/Users/youpude/Library/Developer/Xcode/DerivedData/agriculturalApp-ebtktqjqltyjeegekhyqrvkfgmhp/Build/Products/Debug-iphonesimulator/libDOPDropDownMenu-Enhanced.a(DOPDropDownMenu.o)
duplicate symbol OBJC_IVAR$_DOPDropDownMenu._titles in:
/Users/youpude/Library/Developer/Xcode/DerivedData/agriculturalApp-ebtktqjqltyjeegekhyqrvkfgmhp/Build/Intermediates/agriculturalApp.build/Debug-iphonesimulator/agriculturalApp.build/Objects-normal/x86_64/DOPDropDownMenu.o
/Users/youpude/Library/Developer/Xcode/DerivedData/agriculturalApp-ebtktqjqltyjeegekhyqrvkfgmhp/Build/Products/Debug-iphonesimulator/libDOPDropDownMenu-Enhanced.a(DOPDropDownMenu.o)
duplicate symbol OBJC_IVAR$_DOPDropDownMenu._textColor in:
/Users/youpude/Library/Developer/Xcode/DerivedData/agriculturalApp-ebtktqjqltyjeegekhyqrvkfgmhp/Build/Intermediates/agriculturalApp.build/Debug-iphonesimulator/agriculturalApp.build/Objects-normal/x86_64/DOPDropDownMenu.o
/Users/youpude/Library/Developer/Xcode/DerivedData/agriculturalApp-ebtktqjqltyjeegekhyqrvkfgmhp/Build/Products/Debug-iphonesimulator/libDOPDropDownMenu-Enhanced.a(DOPDropDownMenu.o)
duplicate symbol OBJC_IVAR$_DOPDropDownMenu._separatorColor in:
/Users/youpude/Library/Developer/Xcode/DerivedData/agriculturalApp-ebtktqjqltyjeegekhyqrvkfgmhp/Build/Intermediates/agriculturalApp.build/Debug-iphonesimulator/agriculturalApp.build/Objects-normal/x86_64/DOPDropDownMenu.o
/Users/youpude/Library/Developer/Xcode/DerivedData/agriculturalApp-ebtktqjqltyjeegekhyqrvkfgmhp/Build/Products/Debug-iphonesimulator/libDOPDropDownMenu-Enhanced.a(DOPDropDownMenu.o)
duplicate symbol OBJC_IVAR$_DOPDropDownMenu._indicatorColor in:
/Users/youpude/Library/Developer/Xcode/DerivedData/agriculturalApp-ebtktqjqltyjeegekhyqrvkfgmhp/Build/Intermediates/agriculturalApp.build/Debug-iphonesimulator/agriculturalApp.build/Objects-normal/x86_64/DOPDropDownMenu.o
/Users/youpude/Library/Developer/Xcode/DerivedData/agriculturalApp-ebtktqjqltyjeegekhyqrvkfgmhp/Build/Products/Debug-iphonesimulator/libDOPDropDownMenu-Enhanced.a(DOPDropDownMenu.o)
duplicate symbol OBJC_IVAR$_DOPIndexPath._column in:
/Users/youpude/Library/Developer/Xcode/DerivedData/agriculturalApp-ebtktqjqltyjeegekhyqrvkfgmhp/Build/Intermediates/agriculturalApp.build/Debug-iphonesimulator/agriculturalApp.build/Objects-normal/x86_64/DOPDropDownMenu.o
/Users/youpude/Library/Developer/Xcode/DerivedData/agriculturalApp-ebtktqjqltyjeegekhyqrvkfgmhp/Build/Products/Debug-iphonesimulator/libDOPDropDownMenu-Enhanced.a(DOPDropDownMenu.o)
duplicate symbol OBJC_IVAR$_DOPDropDownMenu._origin in:
/Users/youpude/Library/Developer/Xcode/DerivedData/agriculturalApp-ebtktqjqltyjeegekhyqrvkfgmhp/Build/Intermediates/agriculturalApp.build/Debug-iphonesimulator/agriculturalApp.build/Objects-normal/x86_64/DOPDropDownMenu.o
/Users/youpude/Library/Developer/Xcode/DerivedData/agriculturalApp-ebtktqjqltyjeegekhyqrvkfgmhp/Build/Products/Debug-iphonesimulator/libDOPDropDownMenu-Enhanced.a(DOPDropDownMenu.o)
duplicate symbol OBJC_CLASS$_DOPIndexPath in:
/Users/youpude/Library/Developer/Xcode/DerivedData/agriculturalApp-ebtktqjqltyjeegekhyqrvkfgmhp/Build/Intermediates/agriculturalApp.build/Debug-iphonesimulator/agriculturalApp.build/Objects-normal/x86_64/DOPDropDownMenu.o
/Users/youpude/Library/Developer/Xcode/DerivedData/agriculturalApp-ebtktqjqltyjeegekhyqrvkfgmhp/Build/Products/Debug-iphonesimulator/libDOPDropDownMenu-Enhanced.a(DOPDropDownMenu.o)
duplicate symbol OBJC_METACLASS$_DOPIndexPath in:
/Users/youpude/Library/Developer/Xcode/DerivedData/agriculturalApp-ebtktqjqltyjeegekhyqrvkfgmhp/Build/Intermediates/agriculturalApp.build/Debug-iphonesimulator/agriculturalApp.build/Objects-normal/x86_64/DOPDropDownMenu.o
/Users/youpude/Library/Developer/Xcode/DerivedData/agriculturalApp-ebtktqjqltyjeegekhyqrvkfgmhp/Build/Products/Debug-iphonesimulator/libDOPDropDownMenu-Enhanced.a(DOPDropDownMenu.o)
duplicate symbol OBJC_IVAR$_DOPDropDownMenu._delegate in:
/Users/youpude/Library/Developer/Xcode/DerivedData/agriculturalApp-ebtktqjqltyjeegekhyqrvkfgmhp/Build/Intermediates/agriculturalApp.build/Debug-iphonesimulator/agriculturalApp.build/Objects-normal/x86_64/DOPDropDownMenu.o
/Users/youpude/Library/Developer/Xcode/DerivedData/agriculturalApp-ebtktqjqltyjeegekhyqrvkfgmhp/Build/Products/Debug-iphonesimulator/libDOPDropDownMenu-Enhanced.a(DOPDropDownMenu.o)
duplicate symbol OBJC_IVAR$_DOPDropDownMenu._dataSource in:
/Users/youpude/Library/Developer/Xcode/DerivedData/agriculturalApp-ebtktqjqltyjeegekhyqrvkfgmhp/Build/Intermediates/agriculturalApp.build/Debug-iphonesimulator/agriculturalApp.build/Objects-normal/x86_64/DOPDropDownMenu.o
/Users/youpude/Library/Developer/Xcode/DerivedData/agriculturalApp-ebtktqjqltyjeegekhyqrvkfgmhp/Build/Products/Debug-iphonesimulator/libDOPDropDownMenu-Enhanced.a(DOPDropDownMenu.o)
ld: 20 duplicate symbols for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

为什么重新刷新数据的时候column为-1?

我在加载数据的时候类似tableView的操作, 但是在重新刷新数据的时候出现了问题 DropDown给我返回的colum 为-1 导致我在数组获取数据的时候失败 ,最后跟了您的代码,也发现有这个问题,但是您用if else 吧-1这列数据当做第三列数据,我也准备在我的代码中这样做, 但是您在代码使用说明中并没有提起...

求大神关注我的两个功能需求

功能一:菜单的宽度能否自定义调整,而不是固定满屏
功能二:下拉列表能否增加一个空白的view让我们自定义,加入自己想要的一些元素

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.