Drop down list and Dop up list


download KPDropMenu from Github: Click Here
dropDownViewController.h

#import <UIKit/UIKit.h>
#import "KPDropMenu.h"
@interface dropDownViewController : UIViewController
@property (strong, nonatomic) IBOutlet KPDropMenu *drop;

@end

dropDownViewController.m

#import "dropDownViewController.h"

@interface dropDownViewController ()<KPDropMenuDelegate>

@end

@implementation dropDownViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    _drop.items = @[@"Apple", @"Grapes", @"Cherry", @"Pineapple", @"Mango", @"Orange"];
    _drop.itemsIDs = @[@"0", @"1", @"2", @"3", @"4", @"5"];
    _drop.itemsFont = [UIFont fontWithName:@"Helvetica-Regular" size:12.0];
    _drop.titleTextAlignment = NSTextAlignmentCenter;
    _drop.delegate = self;
    
    /* Adding Menu Programatically*/
    KPDropMenu *dropNew = [[KPDropMenu alloc] initWithFrame:CGRectMake(8, 250, 150, 50)];
    dropNew.delegate = self;
    dropNew.items = @[@"Apple", @"Grapes", @"Cherry", @"Pineapple", @"Mango", @"Orange"];
    dropNew.title = @"Select Again";
    dropNew.itemsFont = [UIFont fontWithName:@"Helvetica-Regular" size:12.0];
    dropNew.titleTextAlignment = NSTextAlignmentCenter;
    dropNew.DirectionDown = NO;
    [self.view addSubview:dropNew];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

#pragma mark - KPDropMenu Delegate Methods

-(void)didSelectItem : (KPDropMenu *) dropMenu atIndex : (int) atIntedex{
    if(dropMenu == _drop)
        NSLog(@"%@ with TAG : %ld", dropMenu.items[atIntedex], (long)dropMenu.tag);
    else
        NSLog(@"%@", dropMenu.items[atIntedex]);
}

-(void)didShow:(KPDropMenu *)dropMenu{
    NSLog(@"didShow");
}

-(void)didHide:(KPDropMenu *)dropMenu{
    NSLog(@"didHide");
}

@end

////City is UIView


Previous
Next Post »

3 comments

Write comments
Unknown
AUTHOR
21 November 2017 at 00:48 delete

Thanks for sharing this code. This is working.

Emu4IOS For IOS

Reply
avatar
Unknown
AUTHOR
1 December 2017 at 21:25 delete This comment has been removed by the author.
avatar
Unknown
AUTHOR
1 December 2017 at 21:25 delete

Is it applicable inside tableview

Reply
avatar