gpt4 book ai didi

ios - swift : How to make Push Notification open to specific tab on tab bar controller

转载 作者:行者123 更新时间:2023-12-01 17:38:55 25 4
gpt4 key购买 nike

我有一个使用 swift 编写的 iOS 8 应用程序。
我的应用程序有一个带有 4 个选项卡的选项卡栏 Controller ,其中一个是“通知”选项卡。

我正在使用 Parse 发送推送通知。当用户从主/锁定屏幕打开推送通知时,我希望它打开到“通知”选项卡

我无法在这里快速找到任何教程或问题来提供帮助。有人可以解释如何做到这一点吗?

我的 AppDelegate 中有这个,但它没有用:

func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject]) {

PFPush.handlePush(userInfo)
let tab :CustomTabBarController = self.window?.rootViewController as CustomTabBarController
tab.selectedIndex = 2
}

最佳答案

更改所选索引不会自动更改显示的 View Controller 。使用 selectedViewController:代替方法。这也将更新选项卡栏上的选定索引。见 Apple Docs .

例子:

tab.selectedViewController = tab.viewControllers[1]

关于ios - swift : How to make Push Notification open to specific tab on tab bar controller,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29184487/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com