-1

当我从 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:)吗?

4

1 回答 1

0

这解决了我的问题:stackoverflow 链接

问题是由于 UIBarButtonItem 不是 UIView 的子类...

于 2012-12-14T11:08:34.460 回答