在一个特定单元格中启动活动指示符

时间:2014-11-17 09:20:27

标签: ios xcode uitableview swift custom-cell

我在自定义单元格的故事板中创建了一个活动指示器。

in cellForRowAtIndexPath:

cell.btnDownload.tag = indexPath.row
cell.btnDownload.addTarget(self, action: "downloadButton:", forControlEvents: .TouchUpInside)

in downloadButton(sender:AnyObject):

let button: UIButton = sender as UIButton;    
let i = NSIndexPath(forRow: button.tag, inSection: 0)
//customCell *cell = (customCell *)[(UITableView *)self.view cellForRowAtIndexPath:i]
//cell.actInd.startAnimating()

在这里,我想获取我当前所在的单元格并启动动画()活动指示器。这是在obj c中这样做的方法吗?如果是这种情况,我该如何为Swift重写这个?

亲切的问候

2 个答案:

答案 0 :(得分:0)

您可以将IBAction方法添加到单元类本身,也可以将委托设置为该类。这样,您就可以轻松访问相应单元格的活动指示器属性

答案 1 :(得分:0)

只需重写我在原始问题中发布的obj c代码,它就可以了。无论如何,请回复。

let cell = self.tableView?.cellForRowAtIndexPath(i)as novelCell