首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >3D触控动作不起作用(迅捷3)

3D触控动作不起作用(迅捷3)
EN

Stack Overflow用户
提问于 2017-05-30 05:57:00
回答 1查看 384关注 0票数 0

所以,我已经把所有的事情都做好了。当按下短键动作时,我会在控制台中得到正确的打印。我从这里要去哪里?我搞不懂..。

这是我在中的代码

代码语言:javascript
复制
    var quicklaunch: Bool!
    var viewName: String?

   func application(application: UIApplication, performActionForShortcutItem shortcutItem: UIApplicationShortcutItem, completionHandler: (Bool) -> Void) {
    viewName = shortcutItem.type
    quicklaunch = true
    completionHandler(quicklaunch)
}

func applicationDidBecomeActive(application: UIApplication) {
    if quicklaunch == true {
        quicklaunch = false
        if viewName == "Messages" {
            let rootViewController = self.window?.rootViewController
            let popUpController = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "FriendsVC")
            rootViewController?.present(popUpController, animated: true, completion: nil)
            print("Worked")
        }
    }  
}

func application(_ application: UIApplication, performActionFor shortcutItem: UIApplicationShortcutItem, completionHandler: @escaping (Bool) -> Void) {
    if quicklaunch == false {
        quicklaunch = true
        if viewName == "Messages" {
            let rootViewController = self.window?.rootViewController
            let popUpController = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "FriendsVC")
            rootViewController?.present(popUpController, animated: true, completion: nil)
            print("Worked")
        }
    }

}

如何让它弹出到正确的视图控制器?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-05-30 07:36:10

您可以获取rootViewController,然后以模式方式呈现所需的viewController (如果rootViewControllerUINavigationController,则将其推到导航堆栈上)。与…有关的东西

代码语言:javascript
复制
let rootViewController = self.window?.rootViewController
let popUpController = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "???") as! ???
rootViewController.present(popUpController, animated: true, completion: nil)

用相应的值替换???

编辑

在AppDelegate中创建一个名为quickLaunch的布尔变量和一个字符串变量viewName。然后更新以下两种方法

代码语言:javascript
复制
func application(application: UIApplication, performActionForShortcutItem shortcutItem: UIApplicationShortcutItem, completionHandler: (Bool) -> Void) {
    viewName = shortcutItem.type
    quickLaunch = true
    completionHandler(quickLaunch)
}

func applicationDidBecomeActive(application: UIApplication) {
    if quickLaunch == true {
        quickLaunch = false
        //PRESENT YOUR VIEW MODALLY HERE
    }  
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44254516

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档