简体   繁体   English

为什么Xcode Storyboard中所做的更改未反映在Simulator / Device上?

[英]Why are the changes made in Xcode Storyboard not getting reflected on Simulator / Device?

I've designed a custom tableview using the storyboard. 我使用情节提要设计了一个自定义表格视图。 When app runs on simulator or iphone, the changes does not show up. 当应用程序在模拟器或iPhone上运行时,更改不会显示。 It still displays last version of the tableview, which does not have Static Cells. 它仍然显示表格视图的最新版本,其中没有静态单元格。

I've tried deleting /Users/xxx/Library/Developer/Xcode/DerivedData directory, cleaning build folder, deleting app on the iPhone and running again, restarting iPhone. 我尝试删除/ Users / xxx / Library / Developer / Xcode / DerivedData目录,清理构建文件夹,删除iPhone上的应用程序并再次运行,然后重新启动iPhone。 Nothing works. 没用。

Storyboard version 故事板版本
What shows on device 设备上显示什么

Here is the code: 这是代码:

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.
}
*/

What else to check or do? 还有什么要检查或做什么?

Runtime Hierarchy 运行时层次结构

Solved. 解决了。 Although I'm designing in the Storyboard the delegate code in the class where returning 0 for the number of rows so logically there were no rows in the iPhone: 尽管我在情节提要中设计类的委托代码,但在逻辑上返回0的行数在iPhone中没有行:

This is the evil code which was commented for the problem to be solved. 这是邪恶的代码,它被评论为要解决的问题。 // MARK: - Table view data source // MARK:-表格视图数据源

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
}

This is a screenshot for the runtime: iPhone Runtime 这是运行时的屏幕截图: iPhone运行时

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Swift XCode-情节提要中的更改未反映在iPhone模拟器中 - Swift XCode - Changes in storyboard aren't being reflected in the iPhone simulator Xcode故事板更改未在设备或模拟器上显示 - Xcode storyboard changes not showing on device or simulator Xcode:为什么相同的故事板设计在模拟器和设备上显示的方式有所不同? - Xcode : Why same storyboard design display differently on simulator and device? 为什么我在情节提要(Xcode)中所做的更改未反映在我的应用程序上? - Why are the changes I make in my Storyboard (Xcode) not being reflected on my app? Xcode 未将代码中的更改反映到模拟器和设备 - Xcode not reflecting changes in the code to the simulator and device 基本情节提要的更改未反映在本地化的情节提要中 - Base Storyboard Changes Not Reflected in Localized Storyboard Xcode故事板模拟器测试 - Xcode Storyboard Simulator test xcode:故事板不反映ViewController.swift中代码中所做的更改 - xcode : storyboard does not reflect changes made in code in ViewController.swift 实际设备未根据Xcode 7.3.1中的iPad故事板显示更改 - Real device not showing changes as per iPad storyboard in Xcode 7.3.1 为什么我的xcode项目建立在模拟器上而不是xcode项目中的设备? - Why does my xcode project build on simulator but not device in xcode project?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM