【问题标题】:How to get a custom table cell view with multiple columns and their contents如何获取具有多列及其内容的自定义表格单元格视图
【发布时间】:2013-06-17 11:25:47
【问题描述】:

我完全是 Mac OSX 开发的新手。我有一个基于视图的 NSTableView,有 3 列。以下是列的结构:

TableColumn1->Table Cell View->NSImageView, NSTextField1, NSTextField2
TableColumn2->Table Cell View->NSImageView
TableColumn3->NSButton

我想控制这些控件的可编辑/隐藏/等属性。例如,我需要根据某些情况在第 3 列隐藏 NSButton(常规按钮,而不是复选框或单选按钮),或者我需要在第 1 列更改 NSTextField2 的文本颜色。

我该怎么做。我在谷歌上搜索过,但没有得到任何合适的解决方案。 :(

我希望我能在这里得到最好的解决方案。谁能帮我摆脱困境?

提前致谢。 :)

【问题讨论】:

    标签: macos nstableview nsbuttoncell nstablecellview


    【解决方案1】:

    我希望您正在设置单元格中包含的所有视图的标签。 首先你必须找到单元格

    UITableViewCell * cell = (UITableViewCell *)[tableView cellForRowAtIndexPath:indexPath];
    

    然后

    UITextField *tempTextField = (UITextField *)[cell.contentView viewWithTag:5];
    tempTextField.text = @""; //what you like to change
    

    希望这会对你有所帮助。

    【讨论】:

    • 感谢您的回复。但我正在开发 Mac OSX 应用程序而不是 iOS 应用程序。 :(
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-12-29
    • 2017-02-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-04-25
    相关资源
    最近更新 更多