【问题标题】:AppDelegate Touch3D Xcode - TabBarAppDelegate Touch3D Xcode - TabBar
【发布时间】:2016-11-10 09:30:25
【问题描述】:

我第一次尝试在 swift 2 中的 xcode 7.3.1 中实现 3D Touch。我在 info.plist 中插入了信息,直到从代码中可以看到打开视图的工作,问题是我没有查看 TabBar ...所以我决定更改所有内容,打开选项卡控制器,然后从那里移到 selectindex = 2 的部分中,但不知道该怎么做...选择索引函数 AppDelegate 工作,有人可以帮助我吗?

这是我在 AppDelegate 中管理 3D Touch 的代码

func application(application: UIApplication, performActionForShortcutItem shortcutItem: UIApplicationShortcutItem, completionHandler: Bool -> Void) {
        //questo codice verrà eseguito ogni volta che le Quick Actions verranno eseguite
        if (shortcutItem.type == "com.tuu.openSearch") {
          //section search THIS WORK without TabBar!!
            let viewcontroller = UIStoryboard.init(name: "Main", bundle: nil).instantiateViewControllerWithIdentifier("searchID")
            dispatch_async(dispatch_get_main_queue(), {
                self.window!.rootViewController?.presentViewController(viewcontroller, animated: false, completion: nil)
            })

        }
        if (shortcutItem.type == "com.tuu.openFavorite"){
            //section tabbar favorite, self.tabBarcontroller.selectedIndex = 2 not work!!
            let viewcontroller = UIStoryboard.init(name: "Main", bundle: nil).instantiateViewControllerWithIdentifier("favoritesID")
            viewcontroller.tabBarController?.selectedIndex = 2
            dispatch_async(dispatch_get_main_queue(), {
                self.window!.rootViewController?.presentViewController(viewcontroller, animated: false, completion: nil)

            })
        }
    }

【问题讨论】:

  • 请告诉我viewController是UIViewController还是UINavgitaionController?
  • 这是 TabController,这实际上是错误...谢谢,现在可以使用

标签: ios swift xcode touch


【解决方案1】:

解决了

if (shortcutItem.type == "com.tuu.openFavorite"){
            let tabBarController = UIStoryboard.init(name: "Main", bundle: nil).instantiateViewControllerWithIdentifier("favoritesID") as! UITabBarController
            tabBarController.selectedIndex = 2
            self.window?.rootViewController = tabBarController

        }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-04-18
    • 2013-01-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-06-10
    • 2011-01-05
    • 2018-12-25
    相关资源
    最近更新 更多