如何以编程方式将UIActivityViewIndicator
置于UITableViewCell
内?
答案 0 :(得分:0)
在UITableViewController
的自定义子类中尝试类似的内容:
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cellIdentifier = "LoadingCell"
var cell = tableView.dequeueReusableCellWithIdentifier(cellIdentifier) as UITableViewCell!
if cell == nil {
cell = UITableViewCell(style: .Default, reuseIdentifier: cellIdentifier)
let activityIndicatorView = UIActivityIndicatorView(activityIndicatorStyle: .Gray)
activityIndicatorView.autoresizingMask = [.FlexibleLeftMargin, .FlexibleRightMargin, .FlexibleTopMargin, .FlexibleBottomMargin]
activityIndicatorView.center = cell.center
cell.contentView.addSubview(activityIndicatorView)
}
return cell
}