强制 NSBrowser 重新加载
我是可可的新手,所以如果这没有意义,我很抱歉。
我正在使用 NSBrowser 从 Web 服务获取某些数据的 Finder 样式列视图。 NSURLConnection
结果是异步返回的。
我的问题是,浏览器在应用程序启动时正确调用其委托来填充列,但一旦获得数据,我就无法重新加载它。
我尝试过 reloadDataForRowIndexes
、noteHeightOfRowsWithIndexesChanged
、addColumn
、reloadColumn
和 loadColumnZero
,但是正如我所期望的那样,它们都不会触发浏览器在委托上调用 numberOfRowsInColumn
(并在启动时看到)。
我知道浏览器委托没问题,因为我可以看到它在启动时被调用。
是否有其他方法要求浏览器刷新,或者我需要尝试其他方法?
B 计划是在另一个线程上触发 urlConnection,并阻止浏览器。我不热衷于阻塞 UI 线程,因为我担心这会导致沙滩球。
C 计划可能会延迟浏览器从 nib 文件加载,直到数据准备好,但我在下一个节点会遇到类似的问题,除非我提前加载一列的所有节点。
I'm new to Cocoa so apologies if this doesn't make sense.
I'm using an NSBrowser
to get a Finder-style column view of some data from a web service.
The NSURLConnection
result is returned asynchronously.
My issue is that the browser correctly calls its delegate to populate columns when the app starts, but I can't make it reload once I've got the data.
I've tried reloadDataForRowIndexes
, noteHeightOfRowsWithIndexesChanged
, addColumn
, reloadColumn
and loadColumnZero
, but none of them trigger the browser to call numberOfRowsInColumn
on the delegate as I would expect (and see on startup).
I know the browser delegate is ok because I can see it being called at startup.
Is there another way to ask the browser to refresh, or do I need to try another approach?
Plan B would be to fire the urlConnection off on another thread, and block the browser. I'm not keen on blocking the UI thread as I fear this will cause a beachball.
Plan C maybe would be to delay the browser loading from the nib file until the data was ready, but I'd have a similar issue next node unless I load all nodes a column early in anticipation.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
[browser reloadColumn:0]
对我不起作用,但[browser loadColumnZero]
不适合我。[browser reloadColumn:0]
did not work for me but[browser loadColumnZero]
.[browser reloadColumn:0]
是正确的方法。这只是有效的,不需要解决方法。如果这对您不起作用,则您的错误在其他地方。[browser reloadColumn:0]
is the right way to go. This just works, no workaround needed. Your error is elsewhere if this does not work for you.