URLPickerController

@objcMembers open class URLPickerController: SDETableViewController

URLPickerController is just a UITableViewController subclass which allows multiple selection and execute a closure with selected strings. If string is not a valid URL, it won’t be displayed in the list.

Sometimes URL link is too long to display completedly in the cell, there are some options to improve it:

  1. adjustsCellFontSizeToFitWidth: The simplest way.
  2. isFileNamePriorThanURL: Only file name is enough sometimes.
  3. shouldDisplayTinyURLAtCellTop: File name loose its location info, fix it by a not very conspicuous way.
  • The designated init method.

    Declaration

    Swift

    public init(URLStrings: [String], pickCompletionHandler: @escaping (_ selectedURLStrings:[String]) -> (), pickButtonTitle: String? = nil)

    Parameters

    URLStrings

    String Array. If string is not a valid URL, it will be filtered.

    pickCompletionHandler

    The closure to execute after tap confirm button in the header view.

    selectedURLStrings

    It’s sure that its count >= 1.

    pickButtonTitle

    Title for confirm and nil by default. The default title for confirm is Pick.

  • No implemented. Don’t init from storyboard/nib file.

    Declaration

    Swift

    required public init?(coder aDecoder: NSCoder)
  • A Boolean value that determines to adjust font size in cell’s textLabel to fit width. The default value is false. If URL link is not very long, this option is suitable, otherwise, it’s better to use isFileNamePriorThanURL and shouldDisplayTinyURLAtCellTop.

    Declaration

    Swift

    public var adjustsCellFontSizeToFitWidth: Bool = false
  • A Boolean value that determines to display file name or URL link. The default value is false. When URL link is too long to display it completely, you could just display file name. If it’s difficult to know where these files come from, you could display a tiny URL link, which is replaced with file name by ***, at the top of cell by shouldDisplayTinyURLAtCellTop.

    Declaration

    Swift

    public var isFileNamePriorThanURL: Bool = false
  • A Boolean value that determines to display a tiny URL link, which is replaced with file name by ***, at the top of cell to tell where file comes from. The default value is false. It’s better to enable isFileNamePriorThanURL if you want to enable this property.

    Declaration

    Swift

    public var shouldDisplayTinyURLAtCellTop: Bool = false
  • Header view height: 40

    Declaration

    Swift

    override open func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat
  • Number of URL to pick.

    Declaration

    Swift

    override open func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int
  • Create a cell before relative row display.

    Declaration

    Swift

    override open func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
  • Provide custom header view. If it returns non-nil, tableView(_:titleForHeaderInSection:) is ignored.

    Declaration

    Swift

    override open func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView?
  • If tableView.isEditing == false, this method is called after you select a cell if any of allowsSelection and allowsMultipleSelection is true; If tableView.isEditing == true, this method is called after you select a cell if any of allowsSelectionDuringEditing and allowsMultipleSelectionDuringEditing is true.

    Declaration

    Swift

    override open func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)
  • If allowsSelection == true && allowsMultipleSelection == false, this method is called after you select another cell; if allowsMultipleSelection == true(allowsSelection is ignored), this method is called after you touch a selected cell(deselect). If tableView.isEditing == true, this method has same behaviors with edit version of these two properties: allowsSelectionDuringEditing and allowsMultipleSelectionDuringEditing.

    Declaration

    Swift

    override open func tableView(_ tableView: UITableView, didDeselectRowAt indexPath: IndexPath)