DownloadActivityTrackable
@objc public protocol DownloadActivityTrackable
Make UITableViewCell coordinate with DownloadListController
to:
- track download activity;
- handle button touch event;
- update button’s title or image.
All properties and methods in the protocol are optional. I have made UITableViewCell conform to this protocol in extension and don’t implement any property or method.
-
Update content of
detailTextLabel
.DownloadTrackerCell
use it to displays download progress info. This method will be called in necessary place if cell implement this method.Declaration
Swift
@objc optional func updateDetailInfo(_ info: String?)
Parameters
info
A string describing download detail, e.g.,
10 KB/117 MB
. -
Update download speed info.
DownloadTrackerCell
add a UILabel at the right of contentView to display speed info. This method will be called in necessary place if cell implement this method.Declaration
Swift
@objc optional func updateSpeedInfo(_ info: String?)
Parameters
info
A string describing download speed, e.g.,
10 KB/s
. If task is not downloading any more, this value is nil. -
Update download progress.
DownloadTrackerCell
add a UIProgressView at bottom of contentView to display progress. This method will be called in necessary place if cell implement this method.Declaration
Swift
@objc optional func updateProgressValue(_ progress: Float)
Parameters
progress
Usually its range is 0.0…1.0, and it’s -1 if progress is unknown.
-
An optional UIButton. In
DownloadTrackerCell
, it’s the assessoryView and used to resume/pause download.Declaration
Swift
@objc optional var accessoryButton: UIButton
-
Assign delegate object to handle button touch event. If you want
DownloadListController
to handle button touch event for your custom UITableViewCell, you should implement this method, and in button action method, send message(only method in protocolAccessoryButtonDelegate
) to its delegate to handle touch event. You could look code ofDownloadTrackerCell
, it’s easy.Declaration
Swift
@objc optional func assignAccessoryButtonDeletegate(_ delegate: AccessoryButtonDelegate)
Parameters
delegate
A delegate object to handle button touch event.
-
Update accessoryButton’s enabled and image. In
DownloadListController
, when its cellAccessoryButtonStyle == .icon, this method will be called in necessary place if cell implement this method.Declaration
Swift
@objc optional func updateAccessoryButtonState(_ enabled: Bool, image: UIImage?)
Parameters
enabled
Enable button or not.
image
Button image.
-
Update accessoryButton’s enabled and title. In
DownloadListController
, when its cellAccessoryButtonStyle == .title, this method will be called in necessary place if cell implement this method.Declaration
Swift
@objc optional func updateAccessoryButtonState(_ enabled: Bool, title: String)
Parameters
enabled
Enable button or not.
title
Button title.