NSOutlineViewoutlineViewSelectionDidChange
我的 NSOutlineView OutlineViewSelectionDidChange 方法将不会被调用。 我将 NSOutlineViews 委托设置为存在其他方法的类
- (BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable:(id)item
。但是在选择项目时不会调用outlineViewSelectionDidChange。 有人有想法吗?
my NSOutlineView outlineViewSelectionDidChange method will not be called.
I set set the NSOutlineViews delegate to the class where the other methods such as
- (BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable:(id)item
exist. But outlineViewSelectionDidChange will not be called on selecting an item.
Does anybody has an idea?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
该通知有点奇怪,因为它不会自动转发给代表。尝试在初始化代码中添加显式注册,如下例所示:
This notification is a bit odd, in that it is not automatically forwarded to delegates. Try adding an explicit registration to your initialization code, like this example:
好的,
同时我发现“NSOutlineViewSelectionDidChangeNotification”只会在通知对象内抛出。所以我必须对 NSOutlineView 进行子类化以捕获通知并将其传递给我需要的对象。
Okay,
meanwhile i figured out that the "NSOutlineViewSelectionDidChangeNotification" will be thrown only within the notification object. So i had to subclass my NSOutlineView to catch the notification and pass it to the object where i need it.
您自己的视图需要符合 NSOutlineViewDelegate 协议,如下所示。
实现中使用此方法
您将在设置大纲视图的 。
加载此视图时
-(void)viewDidLoad
被调用,您的预定义 nib/xib 文件或手动调用将设置您的数据源以根据您的逻辑填充它。现在,在您的
-(void)viewDidLoad
中,您的myoutlineview
需要设置自己的委托,以便您自己的视图可以知道在哪里调用由选择等触发的通知方法。因此,您可以将通知逻辑放置在符合此协议的同一个 View 类中。
Your own view needs to conform to the NSOutlineViewDelegate protocol like so..
you will have this methods in your implementation
where you setup your outlineview.
When loading this view
-(void)viewDidLoad
gets called and your predefined nib/xib file or your manual call will set your datasource to fill it depending on your logic.Now in your
-(void)viewDidLoad
yourmyoutlineview
needs to set its own delegate withso your own View may know where to call its notification methods triggerd from selections and so on. So you can place your notification logic inside the same View class conforming to this protocol.