WeC*_*Can 2 uitableview uipopovercontroller swift
我需要用 tableview 控制器显示一个弹出窗口。
我正在使用以下代码来呈现弹出窗口
func showPopOver() {
让 secondStoryboard = UIStoryboard(name: "Second", bundle: nil)
viewObj = secondStoryboard.instantiateViewControllerWithIdentifier("ViewController") as! ViewController
viewObj.modalPresentationStyle = UIModalPresentationStyle.Popover
viewObj.preferredContentSize = CGSizeMake(400,500)
let popoverPresentationController = viewObj.popoverPresentationController
popoverPresentationController?.delegate = self
popoverPresentationController?.sourceView = self.view //walletButton
popoverPresentationController?.sourceRect = CGRectMake(0, button.frame.origin.y+100, 0, 0)
presentViewController(viewObj, animated: true, completion: nil)
}
Run Code Online (Sandbox Code Playgroud)
//MARK:- UIPopoverPresentationControllerDelegate 方法...开始
func adaptivePresentationStyleForPresentationController(controller: UIPresentationController) -> UIModalPresentationStyle{
return UIModalPresentationStyle.None
}
Run Code Online (Sandbox Code Playgroud)
就像 UIViewController 那么现在我试图加载 UITableViewController 但它不起作用。UIPopover 显示但不显示 tableview。
请建议我提前谢谢
func showPopOver() {
let tableViewController = UITableViewController()
tableViewController.modalPresentationStyle = UIModalPresentationStyle.Popover
tableViewController.preferredContentSize = CGSizeMake(200, 250)
tableViewController.tableView=FontTable
presentViewController(tableViewController, animated: true, completion: nil)
let popoverPresentationController = tableViewController.popoverPresentationController
popoverPresentationController?.sourceView = sender as! UIButton
popoverPresentationController?.sourceRect = CGRectMake(0, 0, sender.frame.size.width, sender.frame.size.height)
popoverPresentationController?.delegate=self
popoverPresentationController?.permittedArrowDirections=UIPopoverArrowDirection.Up
}
func prepareForPopoverPresentation(popoverPresentationController: UIPopoverPresentationController)
{
}
func popoverPresentationControllerDidDismissPopover(popoverPresentationController: UIPopoverPresentationController)
{
}
func popoverPresentationControllerShouldDismissPopover(popoverPresentationController: UIPopoverPresentationController) -> Bool
{
return true
}
Run Code Online (Sandbox Code Playgroud)