小编Chi*_*hip的帖子

为什么我的自定义 UITableViewCell 显示无法正确显示?

我有一个 UITableViewController ,其中有一个原型单元。该单元格中有一个标签和一个文本字段,并且其类设置为InputCell。当表视图加载时,单元格似乎已出列,但显示为默认的空单元格。

我已经检查了以下事项:

  • TableViewController 的类设置为我的 TableViewController 子类(ControlSettingsView)
  • TableViewController 是 TableView 的委托和数据源
  • 自定义单元格的类设置为我的 TableViewCell 子类(InputCell)
  • 自定义单元格重用标识符设置为“input_cell”,这与我的 TableViewController 中使用的标识符匹配。
  • 确保标签和文本字段位于我的单元格内容视图中,而不是单元格本身。
  • 我的单元格中视图的限制看起来很合理。
  • 将单元格背景设置为红色以使其突出,以检查标签和文本字段是否不可见,但单元格是否已正确出列。

从根视图控制器导航到我的设置视图的函数

func gototSettingsFor(control: EditableUIElement) {
        let v = ControlSettingsView()
        self.navigationController?.pushViewController(v, animated: true)
    }
Run Code Online (Sandbox Code Playgroud)

ControlSettingsView.swift

class ControlSettingsView: UITableViewController {

    let INPUT_CELL: String = "input_cell"

    override func viewDidLoad() {
        super.viewDidLoad()
        tableView.register(InputCell.self, forCellReuseIdentifier: INPUT_CELL)
    }

    override func numberOfSections(in tableView: UITableView) -> Int {
        return 1
    }

    override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        switch (section) {
        case 0: …
Run Code Online (Sandbox Code Playgroud)

uitableview ios swift

5
推荐指数
1
解决办法
1644
查看次数

c open()未定义错误:os x上为0

在运行10.8的mac上我试图打开一个串口.

ls/dev/cu*返回:

/dev/cu.Bluetooth-Modem     /dev/cu.Bluetooth-PDA-Sync  /dev/cu.usbserial-A1009TT7
Run Code Online (Sandbox Code Playgroud)

我可以看到端口在那里,但当我尝试打开它时,我得到未定义的错误:0(0).这是我用来打开端口的代码.

char *path = "/dev/cu.usbserial-A1009TT7";

open(path , O_RDWR | O_NOCTTY | O_NONBLOCK);     // open the port

if (file == -1) {
    printf("Error opening port : %s(%d).\n", strerror(errno), errno);
    close(file);
    return -1;
}
Run Code Online (Sandbox Code Playgroud)

任何人都知道为什么港口不会打开?

提前致谢.

c macos serial-port

3
推荐指数
1
解决办法
1150
查看次数

标签 统计

c ×1

ios ×1

macos ×1

serial-port ×1

swift ×1

uitableview ×1