Last active
February 23, 2018 01:24
-
-
Save anzfactory/a4751a81660fce424b1d6127c0ea4191 to your computer and use it in GitHub Desktop.
TWTRTweetTableViewCell on SwipeTableViewCell
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import SwipeCellKit | |
import TwitterKit | |
class SwipeTweetTableViewCell: SwipeTableViewCell { | |
private let innerTweetCell: TWTRTweetTableViewCell = TWTRTweetTableViewCell() | |
override init(style: UITableViewCellStyle, reuseIdentifier: String?) { | |
super.init(style: style, reuseIdentifier: reuseIdentifier) | |
self.contentView.addSubview(self.innerTweetCell.contentView) | |
} | |
required init?(coder aDecoder: NSCoder) { | |
fatalError("init(coder:) has not been implemented") | |
} | |
override func prepareForReuse() { | |
super.prepareForReuse() | |
self.innerTweetCell.prepareForReuse() | |
} | |
override func layoutSubviews() { | |
super.layoutSubviews() | |
// addSubViewする時に制約はって制御したいけど、URLが含まれるツイートの時に微妙にデザインが崩れる(一部制約が取れるのかな?) | |
// ので手動でひろげる。あと、contentViewに対して制約はるとwarning出るし... | |
// ってことでself-sizingではなくなってしまった... | |
self.innerTweetCell.contentView.frame = CGRect( | |
x: 0, | |
y: 0, | |
width: self.contentView.bounds.width, | |
height: self.contentView.bounds.height | |
) | |
} | |
} | |
extension SwipeTweetTableViewCell { | |
func configure(with tweet: TWTRTweet) { | |
self.innerTweetCell.configure(with: tweet) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment