ImageView не отображается - PullRequest
       0

ImageView не отображается

0 голосов
/ 03 марта 2020

Я тренируюсь делать клон instagram, однако, когда я запускаю приложение, изображения по умолчанию и подобные ярлыки не отображаются. куда я иду.

это код для импорта ленты UIKit

 class Feed: UITableViewCell {


@IBOutlet weak var imageee: UIImageView!


@IBOutlet weak var like: UILabel!

@IBOutlet weak var user: UILabel!
@IBOutlet weak var comment: UILabel!



override func awakeFromNib() {
    super.awakeFromNib()
    // Initialization code
}

  override func setSelected(_ selected: Bool, animated: 
   Bool) {
    super.setSelected(selected, animated: animated)

    // Configure the view for the selected state
}
@IBAction func likeButton(_ sender: Any) {
}

Это контроллер представления feedController.

 import UIKit

 class FeedController: UIViewController , 
UITableViewDelegate, UITableViewDataSource {


@IBOutlet weak var tableV: UITableView!
override func viewDidLoad() {
    super.viewDidLoad()
    tableV.delegate = self
  //  tablev.datasource = self
    tableV.dataSource = self

}

 func tableView(_ tableView: UITableView, 
numberOfRowsInSection section: Int) -> Int {
    return 10

}
  func tableView(_ tableView: UITableView, cellForRowAt 
  indexPath: IndexPath) -> UITableViewCell {
    let cell = 


tableView.dequeueReusableCell(withIdentifier:"cellTable" , for: indexPath) as! Feed
       cell.user.text = "testing12"
        cell.like.text = "0"
       cell.comment.text = "comment"
       cell.imageee.image = UIImage(named: "select.png")
      return cell
  }


   }

this is what is showing but i should display the like button and default image view где я иду не так?

1 Ответ

0 голосов
/ 03 марта 2020

Я могу показать вам один пример,

Например, у меня есть следующий ViewController.

import UIKit

class ViewController: UIViewController {

    @IBOutlet weak var tableView: UITableView!
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view.
        tableView.dataSource = self
        tableView.delegate = self
        tableView.register(UINib(nibName: "CustomTableViewCell", bundle: nil), forCellReuseIdentifier: "cell")
    }


}

extension ViewController : UITableViewDelegate , UITableViewDataSource {
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return 10
    }

    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! CustomTableViewCell
        cell.imageView?.image = UIImage(named: "calendar")
        return cell
    }


}

, и это ячейка

import UIKit

class CustomTableViewCell: UITableViewCell {



    @IBOutlet weak var customImage: UIImageView!
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }


}

, и это ее XIB. enter image description here

проверьте, добавляете ли вы изображение в папку Assets.xcassets

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...