简体   繁体   English

午餐后静态3D Touch不显示导航和标签栏

[英]Static 3D Touch not showing navigation and tab bar after lunching

3D Touch is working fine when I press it on the home screen, but not showing the navigation and tab bar, How can I present Navigation and Tab bar using 3D Touch? 当我在主屏幕上按3D Touch时工作正常,但未显示导航和标签栏,如何使用3D Touch显示导航和标签栏? Don't know how to Override point for customization after application launch. 应用程序启动后,不知道如何覆盖自定义点。 Grazie Mille 格拉西·米勒

class AppDelegate: UIResponder, UIApplicationDelegate {    
enum ShortcutIdentifier: String {
    case First
    case Second
    case Third
    case Fourth
    //Initializers
    init?(fullType: String) {
        guard let last = fullType.components(separatedBy: ".").last else { return nil }
        self.init(rawValue: last)
    }
    //Properties
    var type: String {
        return Bundle.main.bundleIdentifier! + ".\(self.rawValue)"
    }
}
var window: UIWindow?

/// Saved shortcut item used as a result of an app launch, used later when app is activated.
var launchedShortcutItem: UIApplicationShortcutItem?

func handleShortCutItem(_ shortcutItem: UIApplicationShortcutItem) -> Bool {
    var handled = false

    // Verify that the provided shortcutItem type is one handled by the application.
    guard ShortcutIdentifier(fullType: shortcutItem.type) != nil else { return false }

    guard let shortCutType = shortcutItem.type as String? else { return false }

    let storyboard = UIStoryboard(name: "Main", bundle: nil)
    var vcc = UIViewController()

    switch (shortCutType) {
    case ShortcutIdentifier.First.type:
        vcc = storyboard.instantiateViewController(withIdentifier: "VC1")
        handled = true
        break
    case ShortcutIdentifier.Second.type:
        vcc = storyboard.instantiateViewController(withIdentifier: "VC2")
        handled = true
        break
    case ShortcutIdentifier.Third.type:
        vcc = storyboard.instantiateViewController(withIdentifier: "VC3")
        handled = true
        break
    case ShortcutIdentifier.Fourth.type:
        vcc = storyboard.instantiateViewController(withIdentifier: "VC4")
        handled = true
        break
    default:
        break
    }
    // Display the selected view controller
    self.window?.rootViewController?.present(vcc, animated: true, completion: nil)

    return handled
}
func application(_ application: UIApplication, performActionFor shortcutItem: UIApplicationShortcutItem, completionHandler: @escaping (Bool) -> Void) {
    let handledShortCutItem = handleShortCutItem(shortcutItem)

    completionHandler(handledShortCutItem)
}
func applicationDidBecomeActive(_ application: UIApplication) {
    guard launchedShortcutItem != nil else { return }

    //handleShortCutItem(shortcut)
    launchedShortcutItem = nil
}

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    // Override point for customization after application launch.
    // If a shortcut was launched, display its information and take the appropriate action
    if let shortcutItem = launchOptions?[UIApplicationLaunchOptionsKey.shortcutItem] as? UIApplicationShortcutItem {

        launchedShortcutItem = shortcutItem
    }
    return true
}

在此处输入图片说明

How can I present Navigation and Tab bar using 3D Touch 如何使用3D Touch显示导航和标签栏

The same way you do it during the normal run of your app. 与您在应用正常运行期间执行操作的方式相同。 You should not be doing some special thing in response to the user pressing the shortcut item (ie your self.window?.rootViewController?.present , which in effect merely puts up a temporary facade); 您不应该对用户按下快捷方式项(即您的self.window?.rootViewController?.present做一些特殊的事情, self.window?.rootViewController?.present这只是建立了一个临时外观。 you should be navigating to the actual area of your real app that the shortcut item corresponds to. 您应该导航到快捷方式项所对应的实际应用程序的实际区域。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM