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

How to add action:@selector to barButton #12

Closed
DimonDeveloper opened this issue Jul 14, 2014 · 3 comments
Closed

How to add action:@selector to barButton #12

DimonDeveloper opened this issue Jul 14, 2014 · 3 comments

Comments

@DimonDeveloper
Copy link

I need to add a method to a barButton.
How to do it?
Thanks.

@TanguyAladenise
Copy link
Owner

Hi,

You are not giving much detail but I guess you want to do that.
The custom view you are using for you barButton should be of class UIButton.
Since it is a UIButton you can add target like you would with any UIButton.

UIButton *customButton = [[UIButton alloc] init];
// Add a target
[button addTarget:self action:@selector(buttonPressed) forControlEvents:UIControlEventTouchUpInside];

// Create and add our custom BBBadgeBarButtonItem with the custom UIButton
BBBadgeBarButtonItem *barButton = [[BBBadgeBarButtonItem alloc] initWithCustomUIButton:customButton];

@DimonDeveloper
Copy link
Author

Thanks a lot 👍 . now I know how to connect a method to a button. :)

@TanguyAladenise
Copy link
Owner

No problem :)

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