繁体   English   中英

如何在情节提要中创建弹出窗口-iOS

[英]How to create popup in storyboard - iOS

我正在使用情节提要创建iPhone应用程序。 在本文中,如何在情节提要板上创建弹出窗口,以及如何在viewcontroller上添加和关闭此弹出窗口。

弹出示例图片:

在此处输入图片说明

我想像这样在情节提要中添加弹出窗口:

在此处输入图片说明

您可以像这样创建它(不要忘记将<UIPopoverControllerDelegate>添加到呈现视图控制器类中)

UIStoryboard* storyboard = [UIStoryboard storyboardWithName : @"MainStoryboard" bundle : nil];
    MyCustomPopoverContentVC* customContentViewController = [storyboard instantiateViewControllerWithIdentifier : @"MyCustomPopoverContentVC"];

// initialize popover controller with content view controller
UIPopoverController* popoverController = [[UIPopoverController alloc] initWithContentViewController: anyCustomViewController];
popoverController.delegate = self;
// change popoverContentSize here
CGRect contentFrame = CGRectMake(0.0, 0, 500.0, 500.0);
popoverController.popoverContentSize = contentFrame.size;
// present popover controller
[popoverController presentPopoverFromRect: _buttonRectForPopoverController inView: self.view permittedArrowDirections: UIPopoverArrowDirectionUp animated: YES];

在呈现视图控制器类的其他地方,有一个示例“ UIPopoverControllerDelegate”方法:

// refreshes the rect from where the popover is shown after interface orientations.
// this method is necessary and recommended by apple's documentation
- (void) popoverController : (UIPopoverController*) popoverController willRepositionPopoverToRect : (inout CGRect*) rect inView : (inout UIView*__autoreleasing*) view
{
    *rect = _buttonRectForPopoverController;
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM