In my app, i need to have a UINavigationController which will have different navigation bar in different view controllers and based on that it will have different UIBarButton items which will required different actions.
Currently what i have is a navigation controller and i am customizing it where ever required and if there are any buttons i need to add i am writing its action method in the same class. But at many places the action is similar so i want to create a common controller for this. i know this is the inefficient way so i was thinking if somebody can guide me on how to make it more productive.
Thanks,
Configuring the bar button item in a UIViewController
base class is the right way to go.
In the base class:
// Configure button.
button.target = self;
button.action = @selector(action:);
// Implement common action.
- (void)action:(id)sender {
…
}
In subclass with special action:
// Implement special action.
- (void)action:(id)sender {
…
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.