3D Touch отлично работает, когда я нажимаю его на главном экране, но не показываю панель навигации и вкладок. Как представить панель навигации и вкладку с помощью 3D Touch? Не знаю, как переопределить точку для настройки после запуска приложения. Grazie MilleСтатическое 3D-касание, не отображающее навигацию и панель вкладок после обеда
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
}
Я не уверен, что означает, что это означает, что этот код находится в моем быстродействующем файле AppDelegate, когда я получаю доступ с помощью 3D Touch на главном экране - его работа, но не отображается панель навигации и вкладок! Нужно ли вводить этот код в ViewController? –
Это не вопрос того, где код. Это вся идея, что вы делаете, это неправильно. Если есть область вашего приложения, в которой есть панель навигации/панель вкладок, тогда ваш ответ на контекстное меню должен быть в _go в эту область вашего приложения_ точно так же, как если бы пользователь перешел к нему обычным способом - не выставлять в качестве презентации специальный специальный диспетчер представлений. – matt
Я знаю, что я делаю неправильно, его не работает! Я до сих пор не понимаю ур точку, мой shortcutitem только в info.plist. Нужно ли создавать ярлык внутри этого контроллера области? Это мое первое приложение, я просто изучаю! –