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.DownloadTrackerCelluse 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
infoA string describing download detail, e.g.,
10 KB/117 MB
. -
Update download speed info.
DownloadTrackerCelladd 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
infoA string describing download speed, e.g.,
10 KB/s
. If task is not downloading any more, this value is nil. -
Update download progress.
DownloadTrackerCelladd 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
progressUsually 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
DownloadListControllerto 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
delegateA 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
enabledEnable button or not.
imageButton 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
enabledEnable button or not.
titleButton title.
View on GitHub
Install in Dash
DownloadActivityTrackable Protocol Reference