使用UIPopover作为注释按钮

时间:2012-11-12 13:28:38

标签: iphone ios uipopovercontroller

我必须创建社交网站的UITableView

现在我卡在uitableview单元格上,其中包含一个评论按钮。

点击该评论按钮,我想创建一个Popover(用户可以在其中输入和发布)。

注意:这是一款不是iPad的iPhone应用程序

可能吗?如果是的话,请帮助我。如果有任何好的教程/示例代码,请告诉我。

3 个答案:

答案 0 :(得分:0)

您无法在iPhone上使用原生UIPopover,但您可以调整一些第三方实施以满足您的需求。

请查看Cocoa Controls了解更多信息。我不认为你必须从零开始。

答案 1 :(得分:0)

有可能。然而,既然你在iPhone上,你需要一个三方游戏类(很可能是WEPopover(https://github.com/werner77/WEPopover

然后,您可以设置弹出框并从按钮显示它。

作为一个简单的iPad示例,这是我创建的一个类,可以让创建UIPopover变得简单:

+(UIPopoverController*)displayPopoverForRowIndex:(NSInteger)index inView:(UIView*)view fromRect:(CGRect)rect withTitle:(NSString*)title permittedArrowDirections:(UIPopoverArrowDirection)direction
{
    UIViewController *contentVC = [[NDSearchDetailsController alloc] initWithIndex:index];
    UINavigationController *navVC = [[UINavigationController alloc] initWithRootViewController:contentVC];

    tableVC.navigationController = navVC;

    UIPopoverController *popover = [[UIPopoverController alloc] initWithContentViewController:navVC];
    tableVC.popoverController = popover;

    popover.delegate = tableVC;

    if (view) [popover presentPopoverFromRect:rect inView:view permittedArrowDirections:direction animated:YES];

    return popover;
}

答案 2 :(得分:0)

Popover controllers are for use exclusively on iPad devices. Attempting to create one on other devices results in an exception.

您可以创建一个背景看起来像popover的视图,并通过更改视图alpha来模拟显示和隐藏的弹出行为。