- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
如何在接收通知时进行后台 API 调用以更新 swift 2.3 中的标签栏角标(Badge)值?
我正在使用以下代码来更新远程通知上的角标(Badge)值:
func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject]) {
pushDictionary = userInfo
NSNotificationCenter.defaultCenter().postNotificationName("PushNotification", object: self, userInfo: userInfo)
let pushNotification = PushNotification(dictionary: pushDictionary!)
notification.subtitleText = pushNotification.message
if application.applicationState == UIApplicationState.Inactive {
if pushNotification.type != nil {
if pushNotification.type == "vc1"{
self.tabBarViewController.selectedIndex = 0
self.tabBarViewController.tabBar.items![0].badgeValue = "1"
self.tabBarViewController.selectedViewController?.viewWillAppear(true)
}
if pushNotification.type == "vc2"{
self.tabBarViewController.selectedIndex = 1
}
if pushNotification.type == "vc3"{
self.tabBarViewController.selectedIndex = 2
}
}
}
let unreadFeeds = feedsDictionary?.objectForKey("UnReadFeeds") as! NSInteger
if unreadFeeds > 0 {
self.tabBarController?.tabBar.items?[0].badgeValue = String(unreadFeeds)
if #available(iOS 10.0, *) {
self.tabBarController?.tabBar.items![0].badgeColor = UIColor(red: 219/255.0, green: 90/255.0, blue: 41/255.0, alpha: 1)
} else {
// Fallback on earlier versions
}
最佳答案
每当用户收到通知时,您都会收到远程通知委托(delegate)方法的回调。如下更新标签栏角标(Badge)。
self.tabBarController?.tabBar.items![0].badgeValue = "YourBadgeValue"
navigation controller
内,你必须使用
self.navigationController!.tabBarItem.badgeValue = "YourBadgeValue"
关于ios - 如何在收到通知时更新 tabBar 角标(Badge)值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42352214/
我想将照片数据从 Tabbarcontroller 中的一个 Viewcontroller(cameraVC) 传递到同一 Tabbarcontroller 中的另一个 Viewcontroller(
我需要加载选项卡栏项目。在这里,我需要不同标签中标签栏的不同背景颜色。我正在更改 didSelectItem 中的栏色调颜色。但它的背景颜色没有改变。加载标签栏时它工作正常。 这是我的代码 over
我想获取标签栏默认大小,但我在ViewController中没有任何tabBar,所以我没有使用self.tabBarController?.tabBar.frame.size.height . 我使
我有一个应用程序的想法,但在使用 Xcode 几个月后,我遇到了一个主要的设计问题。我想要这个: 但正如许多 ios 开发人员所知,在界面构建器中使用传统的标签栏只会创建单色、非轮廓、标签栏按钮,如下
我在我的应用程序上使用 TabBarController,在其中一个主视图 (aViewController) 中,我按下另一个 Controller (bViewController),并使用 se
我想在用户点击选项卡时切换选定的选项卡。假设我有两个选项卡并且显示第一个选项卡,那么点击第一个选项卡(以及点击第二个选项卡)应该会引导我进入第二个选项卡。我已经实现了一个自定义 UITabBarCon
我有一个带有 3 个选项卡的选项卡栏 Controller ,每个选项卡都有导航 Controller ,在每个导航 Controller 的 Root View Controller 上我想要选项卡
我正在编写一个 iPhone 应用程序,它类似于 5-6 级向下钻取应用程序。我几乎完成了我的应用程序的编写,现在提出了一个新要求,即从第三个屏幕开始添加一个 TabBar(JQuery 中的导航栏)
我正在使用 SWRevealViewController 作为侧边菜单。我的应用程序中还有一个标签栏 Controller 作为主视图。 在我的菜单中,我有“MenuItem”(显示MenuItemV
我正在通过 Storyboard 创建一个 TabBar Controller 应用程序。我正在使用 Storyboard 引用对象来链接第三个选项卡项的另一个 Storyboard 。它工作正常,但
TabBar 没有隐藏在推送的 ViewController 中,我使用下面的代码来隐藏 tabBar, tabBarController?.tabBar.isHidden = true
我目前有两个 View Controller ,一个是使用 imagePicker 拍照的 CameraViewController,另一个是显示一个人收到的所有照片消息的 PhotoInboxVie
我有一个包含 5 个项目的 UITabBarController。在其中一个 ViewController 上,我有一个按钮,我将其称为“开始”,所以当我按下开始时,我想插入另一个 ViewContr
我正在更改 setSelectionIndicatorImage,当我在 iOS 8 上运行应用程序时,我得到图像和 tabBar 的常规宽度之间的间距。有没有一种方法可以使标签栏的高度与 setSe
我想通过在图像上向左滑动从“正在显示”导航到“即将推出”,此外,我希望 Appbar 在我滑动时不要移动,但我认为只有标签栏和我不确定,如果您知道如何实现这一点,请提供一些建议 enter image
在我的项目中,我有一个 UITabBarController。在其中一个 ViewControllers 上我有一个按钮。当我单击此按钮时,一个新的 ViewController 将以模态方式呈现。
我是 iPhone 开发新手,多个 View (xib 或 nib)真的让我感到困惑。这就是我想要实现的目标...... 使用 TabBarControllerAppDelegate 有 5 个不同的
滚动到底部后如何修复 iOS 15 标签栏透明: 最佳答案 在 iOS 15 中,Apple 添加了 scrollEdgeAppearance用于在边缘滚动时配置标签栏外观的属性。 https://d
我尝试创建如下图所示的自定义标签栏: 下面是我得到的结果: 以下是我当前的代码: class CustomTabBarController: UITabBarController { over
Widget build(BuildContext context) { return Scaffold( body: SingleChildScrollView( child: Colu
我是一名优秀的程序员,十分优秀!