Ios UITableView单元格上的NSCONTIGUAUSSTRING泄漏
我在Ios UITableView单元格上的NSCONTIGUAUSSTRING泄漏,ios,swift,instruments,Ios,Swift,Instruments,我在ViewController中的仪器上发现nscontiguausstring泄漏,它只有UITableView和UINavigationBar。当viewController出现在UITableViewCells上时,文本不会显示,只显示空白单元格 如果我把它改成 cell.textLabel?.text = NSString(string: dataSource[indexPath.row]) as String 细胞上的文本 控制器类: class FirstSupportedSer
ViewController
中的仪器上发现nscontiguausstring
泄漏,它只有UITableView
和UINavigationBar
。当viewController出现在UITableViewCells
上时,文本不会显示,只显示空白单元格
如果我把它改成
cell.textLabel?.text = NSString(string: dataSource[indexPath.row]) as String
细胞上的文本
控制器类:
class FirstSupportedServicesViewController: BaseViewController {
let bTableView = UITableView()
let dataSource = ["Cell Text 1","Cell Text 2"]
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
bTableView.delegate = self
bTableView.dataSource = self
bTableView.frame = self.view.frame
bTableView.register(BaseCell.self, forCellReuseIdentifier: "SupportedServicesBaseCell")
bTableView.tableFooterView = UIView()
//Prevent TableView Scroll Bug
if #available(iOS 11.0, *) {
bTableView.contentInsetAdjustmentBehavior = .never
} else {
// Fallback on earlier versions
}
self.view.addSubview(bTableView)
let leftButton = UIBarButtonItem(title: "< Geri", style: .plain, target: self, action: #selector(self.backBtnTapped))
self.navigationItem.leftBarButtonItem = leftButton
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@objc func backBtnTapped(){
self.dismiss(animated: true, completion: nil)
}}
extension FirstSupportedServicesViewController: UITableViewDelegate {
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat{
return 44
}
}
extension FirstSupportedServicesViewController: UITableViewDataSource {
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 2
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "SupportedServicesBaseCell", for: indexPath) as! BaseCell
cell.textLabel?.text = dataSource[indexPath.row]
return cell
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let controller = SupportedServicesViewController()
self.navigationController?.pushViewController(controller, animated: true)
tableView.deselectRow(at: indexPath, animated: true)
}
}
class BaseCell: UITableViewCell {
let cellText: UILabel = {
let label = UILabel()
label.textColor = UIColor.black
label.font = Fonts.font
label.adjustsFontSizeToFitWidth = true
return label
}()
override init(style: UITableViewCellStyle, reuseIdentifier: String?){
super.init(style: style, reuseIdentifier: reuseIdentifier)
setupViews()
}
func setupViews() {
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
你读过这篇文章吗?读过。我甚至和博文作者讨论过这个问题,但我们找不到任何解决办法。