Guest User

Untitled

a guest
Nov 22nd, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.65 KB | None | 0 0
  1. func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
  2.  
  3. let post = posts[indexPath.row]
  4. if let cell = tableView.dequeueReusableCell(withIdentifier: "FeedCell") as? FeedCell {
  5.  
  6. cell.caption.text = nil
  7. cell.configureCell(post: post)// sets the caption text here!
  8. cell.caption.sizeToFit()
  9. cell.delegate = self
  10.  
  11. return cell
  12. } else {
  13. return FeedCell()
  14. }
  15. }
  16.  
  17. class FeedCell: UITableViewCell {
  18.  
  19. @IBOutlet weak var caption: UILabel!
  20.  
  21. @IBOutlet weak var activityindicator: NVActivityIndicatorView!
  22.  
  23.  
  24.  
  25. var usersender: User!
  26. var posts: Posts!
  27. var viewRef: DatabaseReference!
  28. var users: User!
  29.  
  30. var delegate: FeedCellDelegate!
  31.  
  32. override func layoutSubviews() {
  33. super.layoutSubviews()
  34.  
  35. contentView.layoutIfNeeded()
  36.  
  37. }
  38.  
  39. func setDelegate(delegate: FeedCellDelegate) {
  40. self.delegate = delegate
  41. }
  42.  
  43. override func awakeFromNib() {
  44. super.awakeFromNib()
  45.  
  46.  
  47. NotificationCenter.default.addObserver(self, selector: #selector(animateIndicator), name: .animateIndicator, object: nil)
  48. NotificationCenter.default.addObserver(self, selector: #selector(stopIndicator), name: .stopIndicator, object: nil)
  49. emotionDisplay.alpha = 0.0
  50.  
  51. caption.addDropShadow(opacity: 3, radius: 8)
  52.  
  53.  
  54. }
  55.  
  56.  
  57. @objc func animateIndicator(note: Notification){
  58. activityindicator.startAnimating()
  59. }
  60.  
  61. @objc func stopIndicator(note: Notification){
  62. activityindicator.stopAnimating()
  63. }
  64.  
  65.  
  66.  
  67.  
  68.  
  69. @IBAction func gotoprof(_ sender: Any) {
  70. self.delegate.segueToUser(user: usersender)
  71. }
  72.  
  73.  
  74.  
  75.  
  76. func configureCell(post: Posts, img: UIImage? = nil) {
  77.  
  78. self.posts = post
  79. self.caption.text = posts.caption
  80.  
  81. }
  82.  
  83. }
Add Comment
Please, Sign In to add comment