问题标签 [nstablecellview]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
519 浏览

swift - How do I set the width of NSTextField inside NSTableColumn

I have an NSTableView with 2 columns where the cells are plain NSTableCellViews and the text of its text field is set from a dictionary.

It is all created in IB where I just drag/dropped a Table view into my app.

My problem is that the cell text is truncated regardless of the width of the column. It does not matter if I set the column width programatically or if I resize it during runtime.

Here is my viewForTableColumn:

Here you can see the result (I'm listing installed apps along with their current version)

This is the output .

As you can see some of the rows with longer names are truncated.

Any pointers on how I can give the text fields the width they need to display all its content ? Either in Xcode/IB or programatically. This is my first OSX app so talk to me like I'm a Windows user ... ;)

0 投票
1 回答
1465 浏览

cocoa - How to create a NSTableview with custom viewcells

I tried many different ways to create a NSTableview with custom NSTableCellView but I could not make it work. The question is, how can I do that thing?

Here is the last thing I tried:

enter image description here

After adding a label:

enter image description here

And the full code:

class ViewController: NSViewController, NSTableViewDelegate, NSTableViewDataSource {

enter image description here

0 投票
1 回答
187 浏览

objective-c - 如何在一个 NSTableCellView 中显示所有对象值?

我有一个 Product 对象,但现在我只能在每个表格单元格视图中打印它的一个值。我想在一个单元格中显示我的对象的所有内容。当我尝试添加另一个值时,它只会抓取我创建的最后一个 cellView。如何用我的所有对象值填充我的单元格?

0 投票
1 回答
998 浏览

objective-c - 更改 NSTableView 选定行的突出显示颜色

如何更改 NSTable 选定行的背景颜色?

这是很好的答案,但它适用于视图。

现在,我看到的是我可以更改选定的高亮样式:

但这里只有 3 个选项;

我尝试了以下解决方案:

它工作正常,但如果我最小化然后再次打开应用程序,仍然显示蓝色

0 投票
1 回答
1151 浏览

objective-c - MakeViewWithIdentifier:owner: 返回 nil

当我尝试为基于视图的每行构造一个视图时,NSTableView该方法makeViewWithIdentifier:owner:始终返回 nil。该表是在 IB 中构建的,所有似乎都正确链接,委托方法都按我的预期调用。在查看有关makeViewWithIdentifier-method 的 Apple 文档时,我找不到该方法返回 nil 的原因。代码片段:

为什么可以view为零?

0 投票
1 回答
561 浏览

arrays - Remove data from array on NSTableView with NSButton with Swift

I have a NSTableView with data populated from an array.

I've created a button which when tapped should remove the items from that row in the array.

I'm struggling with how you remove the data from the array and delete the table column?

My array reference is:

and my table delegate and datasource is:

I've managed to remove the row in the TableView but I'm still struggling with removing the data from the row in the array.

Here's my function to remove the row:

0 投票
1 回答
2684 浏览

swift - 将 NSMenu 添加到右键单击时弹出的 NSTableCellView

我想NSMenu在用户右键单击 aNSTableCellView中的 a 时弹出 a NSTableView

但是如果用户单击单元格,菜单不会弹出。

我找不到任何sendActionOn方法或类似的东西。

如果有人可以提供帮助,那就太好了!

0 投票
2 回答
104 浏览

nstableview - 新 NSTableView 组行的通知

当我的行视图变成组行时,或者更具体地说,当它变成卡在 NSTableview 顶部的组行时,我希望改变它的外观。

我想知道是否有可以检查的通知或某些属性。理想情况下,我想做某种动画,因为它从一个视图到下一个视图的顶部范围内。

我正在考虑跟踪与剪辑视图/滚动视图相关的行视图坐标...您会采用这种方法吗?

有什么建议么?

0 投票
0 回答
1858 浏览

macos - NSTableCellView 动态高度与 NSTextField 多行自动布局

我有一个基于视图的 NSTableView 和 NSTableCellView 子类,它们具有启用自动换行的多行 NSTextField。现在我希望我的表格根据文本字段内容具有动态行高。还启用了自动布局。

文本字段的约束如图所示:

约束

Tableview heightForRow 方法代码:

单元格布局方法:

我尝试了以下链接,但没有任何帮助,文本字段的文本仍在剪切。

0 投票
1 回答
259 浏览

cocoa - 将字段添加到 NSTableCellView

我在 IB 中为 NSTableCellView 添加了一个额外的新标签。

如何连接这个新字段,我可以像 tableView.make( withIdentifier ..

第二个问题:我在尺寸检查器中将 IB 中 TableCellView 的高度更改为 60。IB 中的高度发生变化,但编译后的程序中没有。