![](/img/trans.png)
[英]How to make Popup via storyboard(xib?) and programmatically Xamarin.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.