2016-12-28 80 views
-2

我知道這聽起來會令人困惑,但我正在爲iOS做一個待辦事宜的應用程序,我想要做的是當用戶點擊添加按鈕而不是用戶去另一個視圖控制器輸入新的任務信息,我想要一個小窗口彈出在相同的視圖控制器,然後用戶可以輸入信息。他們是否有辦法做到這一點?如何在Xcode中創建一個窗口

+1

能否請您發表,你已經嘗試過了嗎?請提供[最小,完整和可驗證示例](http://stackoverflow.com/help/mcve)。 – FelixSFD

+0

您正在尋找類似彈出式對話框的東西,進行谷歌搜索 –

+0

@LucaNicoletti謝謝 –

回答

0

如果我沒有錯,你正在談論模態顯示,其中一個視圖將作爲彈出窗口顯示在另一個視圖上。這是如何可以做到:在彈出的視圖

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) 

這將使鑑於

let vc = UIStoryboard.storyboard(storyboard: .Vote).instantiateViewController(YourController.self) 

YourController使用的控制器出現在你的根視圖的彈出

相關問題