- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个 NSMutableArray
,其中包含 NSMutableDictionaries
。我想在 NSTableView
中显示此字典中的一个字符串。该字符串是唯一的默认情况下,它具有一些已知值。插入对象时,如果发现任何重复字符串,则尝试显示警报并使用以下 API 编辑相应的行。
- (void)editColumn:(NSInteger)列行:(NSInteger)行 withEvent:(NSEvent *)theEvent select:(BOOL)select;
这工作正常。
如果用户按下选项卡或按下任何其他 View (放弃FirstResponder
)而不重命名,旧名称仍然存在于tableview
中,我想将此行恢复到编辑模式
。如何实现这一点?
最佳答案
I was able to solve the issue.Modified the alert using sheets.
Following code worked for me.
- (void)controlTextDidEndEditing:(NSNotification *)aNotification
{
if(duplicate)//duplicatefound
{
[self showAlertForDuplicates];
}
}
// Selector
- (void)duplicateAlertDidEnd:(NSAlert *)alert returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo
{
if (returnCode == NSAlertFirstButtonReturn)
{
[self.tableView editColumn:0 row:self.selectedRow withEvent:nil select:NO];
}
}
-(void) showAlertForDuplicates
{
NSAlert *alert = [[[NSAlert alloc] init] autorelease];
[alert addButtonWithTitle:@"Ok"];
[alert setMessageText: @"DuplicateName"];
[alert setInformativeText: @"Rename the item")];
[alert setAlertStyle:NSInformationalAlertStyle];
[alert beginSheetModalForWindow:nil modalDelegate:self didEndSelector:@selector(duplicateAlertDidEnd:returnCode:contextInfo:) contextInfo:nil];
}
关于objective-c - 在 NSTableView 中使用 NSAlerts 编辑重复行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10174899/
非常基本的场景: 我的 Nib 上有一个 NSTableView,有一个指向它的 socket 。我的应用程序委托(delegate)中有以下内容: - (void)applicationDidFin
目前,当我从 NSTableView 中拖出一行时,它是该行中的半透明文本。相反,我想显示代表这一行的半透明图像。 我怎样才能做到这一点? 最佳答案 我建议覆盖 -[NSTableView dragI
我正在使用 NSTableView 来显示我的数据。我想删除默认情况下采用蓝色的选定行的颜色。我可以将其设置为透明颜色吗?可能吗? 编辑: 如何去掉这个蓝色边框?我已将Clear color 设置为表
我正在尝试在 NSTableView 内显示 NSTableView。这是一个类似 iTunes 的专辑/轨道 View 。所以有一个包含 10 张专辑的列表,每个专辑都有一些轨道。我想在外部表格 V
我有一个基于 View 的 NSTableView,其内容绑定(bind)到数组 Controller 。我使用 objectValue.title 绑定(bind)一个特定的文本字段。这工作正常。我
具有单列的基于 View 的 NSTableView。每个“单元格”包含多个 NSTextField、一个 NSImageView 和一个 NSButton,所有这些都绑定(bind)到表格单元格 V
如果我的理解没有错的话,cell-based NSTableView 和 view-based NSTableView 是同一类型的实例。那么,cpu是如何区分cell-based和view-base
我在 10.8 上运行基于 View 的 NSTableView 时遇到问题(目标是 10.7,但我认为这不相关)。 我正在使用 NSTableView,并通过绑定(bind)获取自定义 NSTabl
我有一个有 4 列的 NSTableView。我还为每一行设置了自定义背景颜色。唯一的问题是我有这些丑陋的空白区域,网格线会同时出现在水平轴和垂直轴上。我在 IB 中都取消了检查,但它们仍然出现。如何
我有一个基于 View 的 NSTableView,每一行都必须生成一些需要时间的图像。这些是在后台 NSoperationQueue 上完成的,并在请求图像时启动(通过绑定(bind))。 当一行滚
我的NSTableCellView是子类,并存储指向对象的指针。我想访问该指针,而我唯一获得的信息就是row编号为NSInteger。 如何使用给定的NSTableCellView从我的tableVi
我需要创建一个包含 3 列的 NSTableView,这些列必须适合像这样的空间 20% 60% 20%。我在界面生成器中设置了约束但没有成功。结果总是一样的。显示了 3 列,但大小与 IB 中的相同
我已经尝试了其他帖子中建议选项的多种组合,但我似乎无法使用基于单元格的 NSTableView 填充不可编辑的 NSTextFieldCell 来选择单元格而不是行。 我已经尝试过: [[co
我在区分两个 NSTableView 时遇到问题,需要一些帮助。 我尝试过这些方法: 1. - (void)tableViewSelectionDidChange:(NSNotification *)
我将 NSTableView 绑定(bind)到 NSArrayController。由于某种原因,我根本无法对列进行排序。有些列甚至不显示排序方向箭头。有些确实显示了它,但单击它只是切换箭头方向,它
我在 TableView 中第一行的索引是“0”,这是正确的吗? 如果是,我怎样才能使 TableView 中第一行的索引变为“1”? 这是需要的,因为我的 DataSourse 从“1”开始,我需要
我编写了一个向 NSTableView 添加新行的方法。它添加了新行,但有空,没有文本。代码如下: AppDelegate.h #import @interface AppDelegate : NS
建立委托(delegate)和数据源连接后,我有以下 Controller : #import @interface KextTable : NSObject { @private NSA
我在基于 View 的 NSTableView 中对 NSTableRowView 进行了子类化,以将选择颜色更改为浅蓝色,而不是默认颜色。 不幸的是,当我选择该行时,自定义单元格内的标签和文本字段的
我有一个包含 3 个单元格的 NSTableView。我已经使用以下代码调整了该表格 View 以显示分隔符: [self.tableView setGridColor:[NSColor ligh
我是一名优秀的程序员,十分优秀!