Skip to content

给UITableView增加拷贝

Published: at 11:52 AM | 1 min read

    func tableView(tableView: UITableView, performAction action: Selector, forRowAtIndexPath indexPath: NSIndexPath, withSender sender: AnyObject?) {
        if action == Selector("copy:") {
            if indexPath.row < Data.sharedManager.goodArticle.contentlist.count {
                UIPasteboard.generalPasteboard().string = Data.sharedManager.goodArticle.contentlist[indexPath.row].url
            }
        }
    }
    
    func tableView(tableView: UITableView, canPerformAction action: Selector, forRowAtIndexPath indexPath: NSIndexPath, withSender sender: AnyObject?) -> Bool {
        return action == Selector("copy:")
    }
    
    func tableView(tableView: UITableView, shouldShowMenuForRowAtIndexPath indexPath: NSIndexPath) -> Bool {
        return true
    }