Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
- let post = posts[indexPath.row]
- if let cell = tableView.dequeueReusableCell(withIdentifier: "FeedCell") as? FeedCell {
- cell.caption.text = nil
- cell.configureCell(post: post)// sets the caption text here!
- cell.caption.sizeToFit()
- cell.delegate = self
- return cell
- } else {
- return FeedCell()
- }
- }
- class FeedCell: UITableViewCell {
- @IBOutlet weak var caption: UILabel!
- @IBOutlet weak var activityindicator: NVActivityIndicatorView!
- var usersender: User!
- var posts: Posts!
- var viewRef: DatabaseReference!
- var users: User!
- var delegate: FeedCellDelegate!
- override func layoutSubviews() {
- super.layoutSubviews()
- contentView.layoutIfNeeded()
- }
- func setDelegate(delegate: FeedCellDelegate) {
- self.delegate = delegate
- }
- override func awakeFromNib() {
- super.awakeFromNib()
- NotificationCenter.default.addObserver(self, selector: #selector(animateIndicator), name: .animateIndicator, object: nil)
- NotificationCenter.default.addObserver(self, selector: #selector(stopIndicator), name: .stopIndicator, object: nil)
- emotionDisplay.alpha = 0.0
- caption.addDropShadow(opacity: 3, radius: 8)
- }
- @objc func animateIndicator(note: Notification){
- activityindicator.startAnimating()
- }
- @objc func stopIndicator(note: Notification){
- activityindicator.stopAnimating()
- }
- @IBAction func gotoprof(_ sender: Any) {
- self.delegate.segueToUser(user: usersender)
- }
- func configureCell(post: Posts, img: UIImage? = nil) {
- self.posts = post
- self.caption.text = posts.caption
- }
- }
Add Comment
Please, Sign In to add comment