gpt4 book ai didi

objective-c - 调整 NSMatrix 中 ButtonCell 的大小

转载 作者:行者123 更新时间:2023-12-03 17:11:02 25 4
gpt4 key购买 nike

我正在尝试用 cocoa 实现 Radiogroup 并使用 apple Using Radio Buttons 提供的示例

以下屏幕截图显示了我遇到的问题。即使包含单元格的 NSMatrix 具有足够大的 NSRect,单元格本身也不够宽,无法显示标题。

我该如何纠正这个问题?

enter image description here

<小时/>
NSButtonCell *prototype = [[[NSButtonCell alloc] init]autorelease];
[prototype setButtonType:NSRadioButton];

[prototype setBordered:YES];//only for testing

_view = [[[NSMatrix alloc] initWithFrame:rect
mode:NSRadioModeMatrix
prototype:(NSCell *)prototype
numberOfRows:3
numberOfColumns:1]autorelease];

NSArray *cellArray = [_view cells];
for (std::size_t index = 0; index < 3; ++index)
{
[[cellArray objectAtIndex:index] setTitle:@"a title"];
}

最佳答案

使用矩阵的setCellSize。

NSSize size = [_view cellSize];
size.width = 400;
[_view setCellSize:size];

关于objective-c - 调整 NSMatrix 中 ButtonCell 的大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28275769/

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