romaonthego/REMenu

reMenuItem---Action Block Not Workinh

Opened this issue · 1 comments

__typeof (self) __weak weakSelf = self;
REMenuItem *size350 = [[REMenuItem alloc]initWithTitle:@"Max Size 350" image:nil highlightedImage:nil action:^(REMenuItem *item){
size = 350;
[self savingValues]; // calling method
}];

every thing going right way.. menu open and on click it closes but the action method is not called... plz help on this...

You can use initWithCustomView for menu click action.
Like below code

UIView *itemView1 = [self createCustomMenuItem:@"MenuTitle 1" index:1];
REMenuItem *menuItem1 = [[REMenuItem alloc] initWithCustomView:itemView1];
[self setMemoItemProperty:menuItem1];

UIView *itemView2 = [self createCustomMenuItem:@"MenuTitle 2" index:2];
REMenuItem *menuItem2 = [[REMenuItem alloc] initWithCustomView:itemView2];
[self setMemoItemProperty:menuItem2];
- (UIView *) createCustomMenuItem:(NSString *)title index:(int)index {
    UIButton *customMenuItem = [[UIButton alloc] init];
    customMenuItem.tag = index;
    customMenuItem.titleLabel.font = [UIFont fontWithName:@"OpenSans" size:12.0];
    [customMenuItem setTitle:title forState:UIControlStateNormal];
    [customMenuItem setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [customMenuItem addTarget:self action:@selector(menuItemTapHandler:) forControlEvents:UIControlEventTouchUpInside];
    return customMenuItem;
}
- (void) menuItemTapHandler:(UIButton *)sender {
    [self.menu close];
    int index = (int) sender.tag;    
    if (index == 1) {
        //Item 1 tap
    } else if (index == 2) {
        //Item 2 tap
    }
}