Skip to content

Instantly share code, notes, and snippets.

@mteece
Created November 29, 2012 00:57
Show Gist options
  • Select an option

  • Save mteece/4165964 to your computer and use it in GitHub Desktop.

Select an option

Save mteece/4165964 to your computer and use it in GitHub Desktop.
UIViewController UIBarButtonItem title and add to left/right bar buttons array.
#import "RecentRequestsViewController.h"
#import "AppDelegate.h"
@interface RecentRequestsViewController ()
@end
@implementation RecentRequestsViewController
#pragma mark -
#pragma mark Class initializers.
-(id) initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if(self)
{
// Custom initialization.
self.title = @"Recent Requests";
UIBarButtonItem *recentRequestsButton = [[UIBarButtonItem alloc] initWithTitle:@"Recent Requests"
style:UIBarButtonItemStylePlain
target:self
action:@selector(recentRequestsButtonPressed)];
NSArray *navButtons = [[NSArray alloc] initWithObjects:recentRequestsButton, nil];
self.navigationItem.leftBarButtonItems = navButtons;
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (void)dealloc
{
// Dealloc any resources.
}
#pragma mark -
#pragma mark Class methods
-(void)recentRequestsButtonPressed
{
// Handle SEL here such as transferring to another view controller.
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment