开发者

Reloading NSTableView on re-focus

In my application, I have a NSWindow that has a NSTableView object and a few buttons. When the user presses the "new" button, 开发者_如何学Goan "ItemAdd" NSWindowController is activated where the user types in attributes for the item to be added to the NSTableView.

My question is this: since NSTableView requires reloadDatato update its view, how do I call reloadData after the ItemAdd window closes and focus shifts back to the NSWindow with the NSTableView.

Thanks for the help!


You could put reload data in a notification handler:

Put this in an initialization method of an object that you want the notification to get called on:

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didBecomeMainWindow) name:@"NSWindowDidBecomeKeyNotification" object:nil];

Then make a method something like this:

- (void) didBecomeMainWindow
{
    [tableView reloadData];
}


You can subclass the NSWindow and override the following method:
- (void)becomeKeyWindow

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜