gpt4 book ai didi

ios - 为什么在 Xcode Storyboard 中所做的更改没有反射(reflect)在模拟器/设备上?

转载 作者:行者123 更新时间:2023-11-28 07:37:17 25 4
gpt4 key购买 nike

我使用 Storyboard设计了一个自定义表格 View 。当应用程序在模拟器或 iphone 上运行时,更改不会显示出来。它仍然显示最新版本的 tableview,它没有静态单元格。

我试过删除 /Users/xxx/Library/Developer/Xcode/DerivedData 目录,清理构建文件夹,删除 iPhone 上的应用程序并再次运行,重新启动 iPhone。什么都没用。

Storyboard version
What shows on device

代码如下:

import UIKit

class NewDebtViewController: UITableViewController {

override func viewDidLoad() {
super.viewDidLoad()

// Uncomment the following line to preserve selection between presentations
// self.clearsSelectionOnViewWillAppear = false

// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem


let saveText = NSLocalizedString("Save", comment: "Save")

self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: saveText, style: .done, target: self, action: #selector(saveDebt))
}

//Function to go back
@objc func saveDebt(){

//Here the code for saving the New Debt

//print("Back Button Clicked")
_ = navigationController?.popViewController(animated: true)
}

// MARK: - Table view data source

override func numberOfSections(in tableView: UITableView) -> Int {
// #warning Incomplete implementation, return the number of sections
return 0
}

override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// #warning Incomplete implementation, return the number of rows
return 0
}

/*
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "reuseIdentifier", for: indexPath)

// Configure the cell...

return cell
}
*/

/*
// Override to support conditional editing of the table view.
override func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
// Return false if you do not want the specified item to be editable.
return true
}
*/

/*
// Override to support editing the table view.
override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {
if editingStyle == .delete {
// Delete the row from the data source
tableView.deleteRows(at: [indexPath], with: .fade)
} else if editingStyle == .insert {
// Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
}
}
*/

/*
// Override to support rearranging the table view.
override func tableView(_ tableView: UITableView, moveRowAt fromIndexPath: IndexPath, to: IndexPath) {

}
*/

/*
// Override to support conditional rearranging of the table view.
override func tableView(_ tableView: UITableView, canMoveRowAt indexPath: IndexPath) -> Bool {
// Return false if you do not want the item to be re-orderable.
return true
}
*/

/*
// MARK: - Navigation

// 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.destination.
// Pass the selected object to the new view controller.
}
*/

还有什么要检查或做的?

Runtime Hierarchy

最佳答案

已解决。虽然我在 Storyboard 中设计了类中的委托(delegate)代码,其中返回 0 行数,因此逻辑上 iPhone 中没有行:

这是针对要解决的问题注释掉的恶意代码。 //MARK: - TableView 数据源

override func numberOfSections(in tableView: UITableView) -> Int {
// #warning Incomplete implementation, return the number of sections
return 1
}

override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// #warning Incomplete implementation, return the number of rows
return 4
}

这是运行时的屏幕截图: iPhone Runtime

关于ios - 为什么在 Xcode Storyboard 中所做的更改没有反射(reflect)在模拟器/设备上?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53055886/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com