- (NStableRowVIEw *)outlineVIEw:(NSOutlineVIEw *)outlineVIEw rowVIEwForItem:(ID)item{ ... return rowVIEw;}- (voID)itemDIDExpand:(NSNotification *)notification{ NSDictionary *userInfo = [notification userInfo]; ID item = [userInfo objectForKey:@"NSObject"]; NSOutlineVIEw *outlineVIEw = [notification object]; [outlineVIEw reloadItem:item];}
遗憾的是,这不会重新加载自定义行视图.
重新加载整个NSOutlineVIEw的数据:
- (voID)itemDIDExpand:(NSNotification *)notification{ [outlineVIEw reloadData];}
但是对于大量数据而言,这可能是耗时的,并且经常导致旋转的沙滩球.
是否可以仅为单个顶级项重新加载自定义行视图?
@H_502_4@解决方法 请尝试以下方法:-(voID)outlineVIEw:(NSOutlineVIEw *)outlineVIEw dIDAddRowVIEw:(NStableRowVIEw *)rowVIEw forRow:(NSInteger)row { acolor = [NScolor colorWithCalibratedRed:(r/255.0f) green:(g/255.0f) blue:(b/255.0f) Alpha:1.0]; [vIEw setBackgroundcolor:acolor];}
您可以进一步前进以获取行对象,然后确定特定行所需的颜色.
-编辑-
如果您希望更改父单元格视图以显示它已被展开,那么您已经为NSOutlinevIEw实现了错误的方法.实现如下方法:
-(voID)outlineVIEwItemWillExpand:(NSNotification *)notification { ID theObject = [[notification userInfo] objectForKey:@"NSObject"]; NSInteger row = [theOutlineVIEw rowForItem:theObject]; NStableRowVIEw *theRowVIEw = [theOutlineVIEw rowVIEwAtRow:row makeIfNecessary:NO]; int r = 110; int g = 110; int b = 110; NScolor *acolor = [NScolor colorWithCalibratedRed:(r/255.0f) green:(g/255.0f) blue:(b/255.0f) Alpha:1.0]; [theRowVIEw setBackgroundcolor:acolor];}@H_502_4@ @H_502_4@ @H_502_4@ @H_502_4@ 总结
以上是内存溢出为你收集整理的objective-c – 如何在NSOutlineView中重新加载自定义NSTableRowView?全部内容,希望文章能够帮你解决objective-c – 如何在NSOutlineView中重新加载自定义NSTableRowView?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)