Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reMenuItem---Action Block Not Workinh #128

Open
navanindra opened this issue Apr 8, 2017 · 1 comment
Open

reMenuItem---Action Block Not Workinh #128

navanindra opened this issue Apr 8, 2017 · 1 comment

Comments

@navanindra
Copy link

__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...

@patelhari
Copy link

patelhari commented Nov 1, 2019

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
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants