当我从 IB 中的按钮运行此操作时,该方法被很好地调用。如果我从代码中运行它,应用程序会崩溃,并带有无法识别的选择器发送到实例错误
这是方法:
-(void)bottomCenter:(id)sender
{
[self popover:sender];
}
-(void)popover:(id)sender
{
//the controller we want to present as a popover
DemoTableController *controller = [[DemoTableController alloc] initWithStyle:UITableViewStylePlain];
controller.delegate = self;
popover = [[FPPopoverController alloc] initWithViewController:controller];
//popover.arrowDirection = FPPopoverArrowDirectionAny;
popover.tint = FPPopoverDefaultTint;
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
popover.contentSize = CGSizeMake(300, 500);
}
else {
popover.contentSize = CGSizeMake(200, 300);
}
popover.arrowDirection = FPPopoverArrowDirectionAny;
//sender is the UIButton view
[popover presentPopoverFromView:sender];
}
这就是我从工具栏按钮调用它的方式:
UIBarButtonItem *item3 = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"icons-footer-filter.png"] style:UIBarButtonItemStylePlain target:self action:@selector(bottomCenter:)];
我用 错误地称呼它target:self action:@selector(bottomCenter:)
吗?