ios - 如何在 iPad 中创建 Popover?

标签 ios cocoa-touch ipad uipopovercontroller

<分区>

我想在我的 iPad 应用程序中开发一个弹出窗口。 UIButton 触发器将调用弹出窗口,并且该弹出窗口将包含一个 UITableViewController。

首先我需要一个弹出窗口。

需要一些示例代码或说明或链接。

提前致谢。

最佳答案

在您的 View Controller 中,在按钮操作上编写此代码:

- (IBAction)openAllRhymes:(id)sender{
    UIButton *button = (UIButton*)sender;

    PopupTableView *tableViewController = [[PopupTableView alloc] initWithStyle:UITableViewStylePlain];


    popover = [[UIPopoverController alloc] initWithContentViewController:tableViewController];
    [popover presentPopoverFromRect:CGRectMake(button.frame.size.width / 2, button.frame.size.height / 1, 1, 1) inView:button permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];

    [tableViewController release];
}

现在您已经在该 tableviewcontroller 中为 popover 创建了一个 tableview 写入:

self.clearsSelectionOnViewWillAppear = NO;
self.contentSizeForViewInPopover = CGSizeMake(108,400);

关于ios - 如何在 iPad 中创建 Popover?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6939493/

相关文章:

iphone - iOS 中的两指滑动与一指拖动

objective-c - 如何通过 segue 将数组传递给 tableviewcontroller

iphone - 如果你有很多静态数据,如何遵循 MVC?

ios - 不能使用其他类的 reloadData

ios - 我可以将自定义 Google map 导入 iOS MapKit 吗?

ios - 错误 : unable to load AX Bundle: MapKitFramework. 斧头包。帮助?

iphone - iOS 中的水平 UIScrollView 和数百个缩略图?

ios - UIActivityIndi​​catorView float 在 UITableView 之上

iphone - ARC 过早释放 ViewController

ios - 是否可以使 UITable 连续?