Проблема с вызовом TableViewCell из ViewController
import UIKit
import UIKit
import Firebase
import Firebase Database
import FirebaseAuth
class StocksViewController : UIViewController, UITableViewDataSource, UITableViewDelegate {
@IBOutlet weak var tabelview: UITableView!
var db: FIRDatabaseReference!
var roomsDictionary: NSDictionary?
var needRandomizedRooms = true
var roomKeysArray: NSMutableArray? = []
var mainSearchBar: UISearchBar?
var mainNavigationTitleView: UIView?
var mainRightBarButtonItem: UIBarButtonItem?
var roomKeysArrayForTable:[String] = []
let seporator = " "
var showOnly = "All"
let showOnlyNetwork = "network"
let showOnlyGenre = "genre"
var stringForSampling = ""
deinit {
NotificationCenter.default.removeObserver(self)
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return self.roomKeysArrayForTable.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: StocksTableViewCell.cellIdentifier1(), for: indexPath) as! StocksTableViewCell
let name = self.roomKeysArrayForTable[indexPath.row]
if self.roomsDictionary != nil {
_ = self.roomsDictionary?[name] as! NSDictionary
cell.stocksViewController = nil
}
return cell
}
}
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
// Get the new view controller using segue.destinationViewController.
// Pass the selected object to the new view controller.
}
Код TableViewController
import UIKit
import Firebase
import FirebaseDatabase
import FirebaseAuth
class StocksTableViewCell: UITableViewCell {
@IBOutlet weak var borderview: UIView!
@IBOutlet weak var imageview: UIImageView!
@IBOutlet weak var namelabel: UILabel!
@IBOutlet weak var descriptionlabel: UILabel!
var lastX: CGFloat = 16.0
var stepX: CGFloat = 0.0
var stocksViewController: StocksViewController!
var nameRoom = ""
static func cellIdentifier1 () -> String {
return "StocksViewControllerCell"
}
func configureCell (name: String, dictionary: NSDictionary) {
self.nameRoom = name
self.imageview.image = UIImage(named: "placeholder_image")
self.namelabel.text = name.uppercased()
UICustomizeHelper.roundCornersForView(view: self.borderview)
let storage = FIRStorage.storage()
let storageRef = storage.reference()
let reference = storageRef.child("rooms/"+name+".jpg")
if let cacheUrl = AppData.sharedInstance.cacheRoomImagePathDictionary[name] {
self.imageview.sd_setImage(with: cacheUrl, placeholderImage: UIImage(named: "placeholder_image"))
}
else {
reference.downloadURL { (url, error) in
AppData.sharedInstance.cacheRoomImagePathDictionary[name] = url
self.imageview.sd_setImage(with: url, placeholderImage: UIImage(named: "placeholder_image"))
}
}
(self.subviews as NSArray).enumerateObjects(options: NSEnumerationOptions.reverse) { (value, index, nil) in
if self.subviews[index].tag == 545 {
self.subviews[index].removeFromSuperview()
}
}
func awakeFromNib() {
super.awakeFromNib()
// Initialization code
}
func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
}
}