![](/img/trans.png)
[英]Overlapping UIViewController with another UIViewController Using Swift Programmaticaly
[英]Open new UIViewController using Swift
使用CoreGraphics ,我可以獲得點擊位置。
我的要求是根據對圖像不同區域的點擊來打開不同的UIViewController
。
您需要使用以下方法之一基於觸摸的位置創建一個新的UIViewController
:
手動創建
let controller = SubclassViewController() //prepare your view controller here
從情節提要實例化控制器
if let controller = storyboard.instantiateViewControllerWithIdentifier("identifier") as? SubclassViewController { //prepare your view controller here }
對新視圖控制器執行segue
performSegueWithIdentifier("segueIdentifier")
然后在prepareForSegue:
准備您的視圖控制器prepareForSegue:
if let controller = segue.destinationViewController as? SubclassViewController { //prepare your controller here }
根據您的應用程序在做什么,您可以推送新的視圖控制器或手動顯示它
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.