我试图将 barbuttonitem 添加到 xcode proj 中,最后使用视图控制器显示它并将代码放在视图中确实加载部分,但我无法连接操作......我一直使用界面构建器和 IBOutlets 但那不是一个选项,因为必须以编程方式放入此导航控制器才能使标签栏控制器工作
- (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.
}
这是我第一次尝试在不使用 IBOutlet 和界面构建器的情况下将操作放在一起,所以我确信它看起来很糟糕,目标是使用 FPPopover 并让导航栏按钮项目在按下时显示一个弹出窗口
-(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:];
}