0

I am using progress view to display download indication. Downloading successfully. But, I am using 5 progress view which I have showed in UITableViewCell. That cell, having START, PAUSE, RESUME buttons and 1 progress view. If I click start button, task getting initiating, automatically 5 cells get starts to load. Though I am clicking first cell, all progress view gets loaded. Kindly, guide me. I need, progress view gets loaded for which cell's START I pressed. I need to load URL independently. Kindly help me.

My Coding below:

lazy var session : NSURLSession = {
        let config = NSURLSessionConfiguration.ephemeralSessionConfiguration()
        config.allowsCellularAccess = false
        let session = NSURLSession(configuration: config, delegate: self, delegateQueue: NSOperationQueue.mainQueue())
        return session
        }()

func URLSession(session: NSURLSession, downloadTask: NSURLSessionDownloadTask, didWriteData bytesWritten: Int64, totalBytesWritten writ: Int64, totalBytesExpectedToWrite exp: Int64) {
        println("downloaded \(100*writ/exp)")
        taskTotalBytesWritten = Int(writ)
        taskTotalBytesExpectedToWrite = Int(exp)
        percentageWritten = Float(taskTotalBytesWritten) / Float(taskTotalBytesExpectedToWrite)

        downLoadTblVw.delegate = self
        downLoadTblVw.reloadData()

    }

START BUTTON IB ACTION

var btnPos: CGPoint = sender.convertPoint(CGPointZero, toView: downLoadTblVw)
var indePath: NSIndexPath = downLoadTblVw.indexPathForRowAtPoint(btnPos)!

buttonTag = indePath.row

switch(buttonTag)
        {
        case 0:

            let s = "http://www.qdtricks.com/wp-content/uploads/2015/02/hd-wallpapers-1080p-for-mobile.png"
            let url = NSURL(string:s)!
            let req = NSMutableURLRequest(URL:url)
            let task = self.session.downloadTaskWithRequest(req)
            self.task = task

            task.resume()

            break
        default:
            println("WRONG BUTTON PRESSED")
            break
        }

cellForRowAtIndexPath

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
    let cell = downLoadTblVw.dequeueReusableCellWithIdentifier("download", forIndexPath: indexPath) as downLoadingTblVwCell

    cell.progressView.progress = percentageWritten


    return cell
}
McDonal_11
  • 3,935
  • 6
  • 24
  • 55
  • I think we might need more code and a slightly more precise description of the problem you're having. Just to clarify though - are you are using IBOutlet touchUpInside actions to get the button presses? Why are you converting points? – Mark Jun 22 '15 at 11:49
  • yes! I am using IBOutlet only. Not selector. 5 cell is there. I want to check, 0th cell's Start button if I click, 0th progress view get load. So that, I am getting which cell's button I am clicking. – McDonal_11 Jun 22 '15 at 11:58
  • If I need to get, 3rd cell of progress view means, how can I get?? – McDonal_11 Jun 22 '15 at 12:00
  • There are better ways to do that - such as subclassing and setting delegates and so forth, but the easiest way here would be to call `button.superview`, to get the cell that it's contained in – Mark Jun 22 '15 at 12:02
  • how to solve my issue??? – McDonal_11 Jun 22 '15 at 12:08
  • Like I said, I think we might need more code. I suspect you may have an issue with your implementation of the `dataSource` methods, perhaps returning the same cell for all rows? – Mark Jun 22 '15 at 12:12

0 Answers0