I attempted to add the barbuttonitem into the xcode proj and finally got it to show up using the view controller and putting the code in the view did load section but I cannot connect the action... I have always used interface builder and IBOutlets but that is not an option as this navigation controller had to be programmatically put in to have the tab bar controller work
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
//add navbar buttons progamatically b/c nothing to use in xibs...
UIBarButtonItem * popbutt = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(apopbuttonPressed:)];
UINavigationItem * navigItem = [[UINavigationItem alloc]initWithTitle:@"Scribbler"];
navigItem.rightBarButtonItem = popbutt;
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
This is my first attempt at putting actions together without using IBOutlet and interface builder so I'm sure it looks pretty bad the goal is to use FPPopover and have the nav bar button item display a popover when pressed
-(void)apopbuttonPressed
{
//the controller we want to present as popover
ScribblePopoverViewController * controller = [[ScribblePopoverViewController alloc] initWithStyle:UITableViewStylePlain];
controller.delegate = self;
apop = [[FPPopoverController alloc] initWithViewController:controller];
//apop.arrowDirection = FPPopoverArrowDirectionAny;
apop.tint = FPPopoverDefaultTint;
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
apop.contentSize = CGSizeMake(300, 500);
}
else {
apop.contentSize = CGSizeMake(200, 300);
}
apop.arrowDirection = FPPopoverArrowDirectionAny;
//sender is the UIButton view
// idk [apop presentPopoverFromView:];
}
- (void)viewDidLoad { [super viewDidLoad]; NSLog(@"viewdidload"); // Do any additional setup after loading the view, typically from a nib. UIBarButtonItem * popbutt = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(apopbuttonPressed:)]; self.navigationItem.rightBarButtonItem = popbutt; } - (void) apopbuttonPressed:(id) sender { NSLog(@"pressed"); }
– Thorsten