我知道这听起来很混乱,但我正在为iOS制作一个待办事项应用程序,我想要做的是当用户点击添加按钮时,而不是用户转到另一个视图控制器进入新任务信息,我想在同一个视图控制器中弹出一个小窗口,然后用户可以输入信息。他们是这样做的吗?
答案 0 :(得分:0)
如果我没有错,你正在谈论模态演示,其中视图将作为弹出窗口显示在另一个视图上。这是如何做到的:
let vc = UIStoryboard.storyboard(storyboard: .Vote).instantiateViewController(YourController.self)
在YourController
下使用弹出视图的控制器
vc.modalPresentationStyle = .popover
let nav = UINavigationController(rootViewController: vc)
nav.modalPresentationStyle = UIModalPresentationStyle.popover
let popover = nav.popoverPresentationController
vc.preferredContentSize = CGSize(width: 280,height: 300) //use own height and width
vc.navigationController?.isNavigationBarHidden = true
popover!.delegate = self
popover!.sourceView = self.view
popover!.sourceRect = CGRect(x: self.view.bounds.midX, y: self.view.bounds.midY - 20,width: 0,height: 0)
popover!.permittedArrowDirections = UIPopoverArrowDirection(rawValue: 0)
self.present(nav, animated: true, completion: nil)
这将使视图在根视图中显示为弹出窗口