Luciano Nascimento
Luciano Nascimento

Reputation: 2600

How to do that button action as a direct command

I have a button that call function togglemenu at self.navigationController. It works properly.

[btnMenu addTarget:self.navigationController action:@selector(toggleMenu) forControlEvents:UIControlEventTouchUpInside];

How Can I call it as a direct command? Like:

[self.navigationController toggleMenu]; // Not working

Upvotes: 0

Views: 71

Answers (3)

Arun
Arun

Reputation: 476

Try this,

[self.navigationController performSelector:@selector(toggleMenu)];

Upvotes: 2

Sumit Mundra
Sumit Mundra

Reputation: 3901

you have two method to do this

1) [self.navigationController performSelector:@selector(toggleMenu)];

2)  get your customenavigtion contoller class instanse and call this method

 NavigationViewController *navigationController = (NavigationViewController *)self.navigationController;
   [navigationController toggleMenu];

Upvotes: 1

Ahmed Z.
Ahmed Z.

Reputation: 2337

simply you have to use [self toggleMenu]; for method calling

Upvotes: -2

Related Questions