当应用程序从未运行变为活动状态时,如何读取日志? [关闭]

问题描述 投票:0回答:2
我的应用程序的3D触摸在强制关闭应用程序时不起作用(当应用程序窗体挂起并处于活动状态时,它运行良好)。因此,我想捕获launchOptions的日志。

但是,当我强制关闭应用程序时,控制台不再捕获日志。

请告诉我该怎么办?

ios swift
2个回答
1
投票
[当您强制关闭应用程序时,您的Xcode会停止执行它,您可以在附加该应用程序后再次执行该操作。一旦将其关闭,请再次打开该应用程序(一旦被强行关闭),然后转到

Debug> Attach to Process,您的应用程序名称应存在,选择它,它将等待该应用程序启动,这可以正常工作使用设备,不确定使用模拟器。


0
投票
尝试此

info.plist

<key>UIApplicationShortcutItems</key> <array> <dict> <key>UIApplicationShortcutItemSubtitle</key> <string>Add New User</string> <key>UIApplicationShortcutItemType</key> <string>com.vss.Qiuck-Action-Sample.Add</string> <key>UIApplicationShortcutItemTitle</key> <string>Add</string> <key>UIApplicationShortcutItemIconType</key> <string>UIApplicationShortcutIconTypeAdd</string> </dict> </array>

AppDelegate.swift

import UIKit @UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { // Override point for customization after application launch. if let shortcutitem = launchOptions?[UIApplication.LaunchOptionsKey.shortcutItem] as? UIApplicationShortcutItem { if shortcutitem.type == "com.vss.Qiuck-Action-Sample.Add" { let storyBoard = UIStoryboard(name: "Main", bundle: nil) let vc = storyBoard.instantiateViewController(identifier: "AddViewController") as! AddViewController self.window?.rootViewController = vc } } return true } }

© www.soinside.com 2019 - 2024. All rights reserved.