【发布时间】:2017-04-16 05:13:22
【问题描述】:
我必须在以下代码中使用 Reactive Cocoa 或 RxSwift 来实现动态标签高度和动态行高。
我可以在 Swift3 中使用 Reactive Cocoa 吗? ReactiveCocoa 和 RxSwift 有什么区别?
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell: BTSTableViewCell = self.tableView.dequeueReusableCell(withIdentifier: "BTSTableViewCellIdentifier")! as! BTSTableViewCell
cell.configureWithPost(posts[indexPath.row])
cell.delegate = self
return cell
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
// 259.5+ labelHeight+ bigImageHeight
let postViewModel = posts[indexPath.row]
//caption height
var captionHeight = postViewModel.textDetail?.height(withConstrainedWidth: tableView.bounds.size.width - 20, font: UIFont.systemFont(ofSize: 17))
captionHeight = ceil(captionHeight!)
var finalCaptionHeight: CGFloat = 0.0;
if postViewModel.showDetailedCaption {
finalCaptionHeight = captionHeight!
}
else {
finalCaptionHeight = min(41, captionHeight!)
}
return 259.5 + postViewModel.getBigImageHeightFor(tableView.bounds.size.width) + finalCaptionHeight
}
【问题讨论】:
-
@Peres 回答了您的问题,但我想知道,为什么您认为“必须使用 Reactive Cocoa 或 RxSwift [...] 来实现动态标签高度和动态行高”?
-
@Sebastian 实际上,我需要使用它,因为这是我的要求。
标签: ios swift3 reactive-cocoa rx-swift