Since the previous use of the drop-down menu, so now take some time to go back to carefully organize a bit, gradually improve the drop-down menu, and provide some more basic functions, so that in future if necessary, can be reused, and provide to the people who need reference. The drop-down menu is also divided into data sources and proxy methods, providing the following methods:
1 //2 //XWDropdownMenu.h3 //Xwreusablecodelib4 //5 //Created by Xiao on 15/10/30.6 //copyright©2015 year Xiao. All rights reserved.7 //Drop- down menu8 9 #import<UIKit/UIKit.h>Ten One @classXwdropdownmenu; A #pragmaMark Data Source Method - @protocolXwdropdownmenudatasource <NSObject> - @required the /** - * How many lines are there in the main table? - */ --(Nsinteger) numberofrowsinmaintable: (Xwdropdownmenu *) Dropdownmenu; + /** - * Title of each row of the main table + * @param row number A */ at-(NSString *) Dropdownmenu: (Xwdropdownmenu *) Dropdownmenu titleforrowinmaintable: (nsinteger) row; - /** - * Sub-data array for each row of the main table - * @param row number - */ --(Nsarray *) Dropdownmenu: (Xwdropdownmenu *) Dropdownmenu subdataforrowinmaintable: (nsinteger) row; in @optional - /** to * Number of categories per row of Main Table + * @param row number - */ the-(NSString *) Dropdownmenu: (Xwdropdownmenu *) Dropdownmenu countforrowinmaintable: (nsinteger) row; * /** $ * sub-table each row sub-data category numberPanax Notoginseng * @param row number - */ the-(Nsarray *) Dropdownmenu: (Xwdropdownmenu *) Dropdownmenu subdatacountforrowinsubtable: (nsinteger) row; + /** A * Icons for each row of the main table the * @param row number + */ --(NSString *) Dropdownmenu: (Xwdropdownmenu *) Dropdownmenu iconforrowinmaintable: (nsinteger) row; $ /** $ * The selected icon for each row of the sub-table - * @param row number - */ the-(NSString *) Dropdownmenu: (Xwdropdownmenu *) Dropdownmenu selectediconforrowinmaintable: (nsinteger) row; - @endWuyi the #pragmaMark Proxy method - @protocolXwdropdownmenudelegate <NSObject> Wu - @optional About- (void) Dropdownmenu: (Xwdropdownmenu *) Dropdownmenu didselectrowinmaintable: (nsinteger) row; $- (void) Dropdownmenu: (Xwdropdownmenu *) Dropdownmenu didselectrowinsubtable: (nsinteger) Subrow inmaintable: (Nsinteger) Mainrow; - - @end - A #pragmaMark Construction Method + @interfaceXwdropdownmenu:uiview the+(instancetype) Dropdownmenu; --(void) Refreshmenu; $ the@property (nonatomic, weak)ID<XWDropdownMenuDataSource>DataSource; the@property (nonatomic, weak)ID<XWDropdownMenuDelegate>Delegate; the the /** Main Table is selected font color, default is black*/ -@property (Strong, nonatomic) Uicolor *Selectedrowtextcolor; in /** This property is set to Yes, and the main table is relatively small*/ the @property (nonatomic, assign) BOOL Ismaintablesmall; the @end
Since there is still some code, it is not possible to post all the code here, only to list the various methods and add comments, and attach a simple demo and
Demo Address: Https://github.com/xiaoyeying/XWDropdownMenuDemo.git
Finally, if there are shortcomings, please correct and criticize, study together ~ ~
IOS drop-down menu multiplexing