Reuse of IOS drop-down menus and ios drop-down menus

Source: Internet
Author: User

Reuse of IOS drop-down menus and ios drop-down menus

Since I used the drop-down menu before, I have spent some time looking back and finishing it, gradually improving the drop-down menu and providing some basic functions, in this way, you can reuse it if necessary in the future and provide it to users who need it for reference. The drop-down menu is also divided into data source and proxy methods. The following methods are provided:

1 // 2 // XWDropdownMenu. h 3 // XWReusableCodeLib 4 // 5 // Created by xiao on 15/10/30. 6 // Copyright©2015 xiao. all rights reserved. 7 // drop-down menu 8 9 # import <UIKit/UIKit. h> 10 11 @ class XWDropdownMenu; 12 # pragma mark Data Source Method 13 @ protocol XWDropdownMenuDataSource <NSObject> 14 @ required15/** 16 * Total number of rows in the master table 17 */18-(NSInteger) numberOfRowsInMainTable :( xwdropdowndownmenu *) dropdownMenu; 19/** 20 * Title of each row in the main table 21 * @ param row 22 */23-(NSString *) dropdownMenu :( XWDropdownMenu *) dropdownMenu titleForRowInMainTable :( NSInteger) row; 24/** 25 * array of child data in each row of the main table 26 * @ param row 27 */28-(NSArray *) dropdownMenu :( XWDropdownMenu *) dropdownMenu subdataForRowInMainTable :( NSInteger) row; 29 @ optional30/** 31 * Number of classes per row in the master table 32 * @ param row 33 */34-(NSString *) dropdownMenu :( XWDropdownMenu *) dropdownMenu countForRowInMainTable :( NSInteger) row; 35/** 36 * Number of subdata categories for each row in the subtable 37 * @ param row 38 */39-(NSArray *) dropdownMenu :( XWDropdownMenu *) dropdownMenu subdataCountForRowInSubTable :( NSInteger) row; 40/** 41 * icon 42 * @ param row 43 */44-(NSString *) dropdownMenu :( XWDropdownMenu *) dropdownMenu iconForRowInMainTable :( NSInteger) row; 45/** 46 * selected icon for each row in the subtable 47 * @ param row 48 */49-(NSString *) dropdownMenu :( XWDropdownMenu *) dropdownMenu selectedIconForRowInMainTable :( NSInteger) row; 50 @ end51 52 # pragma mark proxy method 53 @ protocol failed <NSObject> 54 55 @ optional56-(void) dropdownMenu :( XWDropdownMenu *) dropdownMenu didSelectRowInMainTable :( NSInteger) row; 57-(void) dropdownMenu :( XWDropdownMenu *) dropdownMenu didSelectRowInSubTable :( NSInteger) subrow inMainTable :( NSInteger) mainRow; 58 59 @ end60 61 # pragma mark constructor 62 @ interface XWDropdownMenu: UIView63 + (instancetype) dropdownMenu; 64-(void) refreshMenu; 65 66 @ property (nonatomic, weak) id <XWDropdownMenuDataSource> dataSource; 67 @ property (nonatomic, weak) id <XWDropdownMenuDelegate> delegate; 68 69/** the selected font color of the master table. The default color is black */70 @ property (strong, nonatomic) UIColor * selectedRowTextColor; 71/** set this attribute to YES. The master table is relatively small */72 @ property (nonatomic, assign) BOOL isMainTableSmall; 73 @ end

Because there are still some code, you cannot post all the code here. You can only list each method and add comments, and attach a simple demo and

Demo address: https://github.com/xiaoyeying/XWDropdownMenuDemo.git

In the end, if you have any shortcomings, please refer to and criticize and learn together ~~

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.