2017-04-15 46 views
0

我必須在下面的代碼中使用Reactive Cocoa或RxSwift來獲得動態標籤高度和動態行高度。我可以在swift 3中使用ReactiveCocoa嗎?

我可以在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 

} 
+0

@Pres回答你的問題,但我想知道,你爲什麼認爲你「必須使​​用Reactive Cocoa或RxSwift [...]來獲取動態標籤高度和動態行高度」? –

+0

@Sebastian其實,我需要使用它,因爲這是我的要求。 – Bharath

回答

2

我可以使用無可可Swift3?

是的,你可以。該項目是located here。重要的是要注意ReactiveCocoa只有UI綁定,而實際的「引擎」被稱爲ReactiveSwift

ReactiveCocoa和RxSwift有什麼不同?

你可以找到一個比較here。但底線,兩者都是兩個非常有能力的框架。不管你選擇哪一個,你都不會錯。

+0

謝謝。你能幫我把上面的代碼轉換成RxSwift嗎? – Bharath

+1

@Bharath除了你的問題的範圍。請將此答案標記爲已更正(如果您認爲如此)並打開一個新問題。 – Peres

相關問題