TabBarBadgeCount

This commit is contained in:
Chris Li 2016-08-29 10:03:41 -04:00
parent 4ff054f0e5
commit 8714e2cf7d
3 changed files with 9 additions and 2 deletions

View File

@ -22,6 +22,7 @@ class DownloadTasksController: UITableViewController, NSFetchedResultsController
tabBarItem.title = LocalizedStrings.LibraryTabTitle.download
tabBarItem.image = UIImage(named: "Download")
tabBarItem.selectedImage = UIImage(named: "DownloadFilled")
refreshTabBarBadgeCount()
}
override func viewDidLoad() {
@ -77,6 +78,11 @@ class DownloadTasksController: UITableViewController, NSFetchedResultsController
}
}
func refreshTabBarBadgeCount() {
guard let count = fetchedResultController.fetchedObjects?.count else {return}
tabBarItem.badgeValue = count > 0 ? "\(count)" : nil
}
// MARK: - TableView Data Source
override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
@ -214,6 +220,7 @@ class DownloadTasksController: UITableViewController, NSFetchedResultsController
func controllerDidChangeContent(controller: NSFetchedResultsController) {
tableView.endUpdates()
refreshTabBarBadgeCount()
}
}

View File

@ -49,7 +49,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>1.7.1481</string>
<string>1.7.1486</string>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>LSRequiresIPhoneOS</key>

View File

@ -21,7 +21,7 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.7.1833</string>
<string>1.7.1839</string>
<key>NSExtension</key>
<dict>
<key>NSExtensionMainStoryboard</key>