ew第二次加载其customcell子视图的更改它的位置如何解决

ew第二次加载其customcell子视图的更改它的位置如何解决

本文介绍了当NSTableview第二次加载其customcell子视图的更改它的位置如何解决的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新的可可OSX应用程序可能是这个问题很简单,但我尽我所能找出这个问题,最后我在这里问问题。

I am new for cocoa OSX application might be this question is simple but i try my best to find out this issue and at the end i asking question here.

我创建 NSWindowViewController ,在其中我使用 NSTableview 与Customcell。在customeCell我使用NSView(customView)和所有单元IBOutlet放在侧NSView。当第一次 NSWindowViewController 加载显示精细,但关闭窗口后,我再次打开它。它的 NSTextField IBOutlet更改其位置顶部到单元格的底部。

I am creating NSWindowViewController and in side it i Used NSTableview with Customcell. In customeCell i used NSView (customView) and all Cell IBOutlet put in side NSView. When First time that NSWindowViewController load that show fine but after close the window and again i open it. its NSTextField IBOutlet change its position top to bottom of the cell.

我尝试找到这个属性更改,没有修复它我附加其屏幕示例发生了什么,我的可可osx应用程序。

I try to find this some property change but did not fix it i attach its screen example what was happen with my cocoa osx Application.

推荐答案

我注意到这发生,当我使用下面的代码设置NSview的属性检查器的背景颜色设置NSView核心动画。

I notice that this happen when i used following code for setting NSview's background color from property Inspector i setting NSView Core animation like.

并在 viewForTableColumn 中设置背景颜色like:

And set background color in viewForTableColumn like:

cellView.bgview.layer.backgroundColor = [NSColor whiteColor].CGColor;

颜色设置正确,所有工作正常,当我重新加载表视图顶部标签到底部,显示反转单元格的UI顺序,如我在问题中所示。

Color set properly and all working fine when i reload table view that top label going to bottom and that will display revers UI order for cell as i show in my question.

我测试了如果我删除NSView设置背景颜色代码如上所述,秩序和所有的东西。我不使用自动布局。

And i tested with if i remove NSView setting background color code as i mention above then working perfect no re-order and all things. I am not using Auto-layout.

之后,我创建自定义子类NSview设置颜色,如下:

So after then i create custom subclass of NSview for setting color like following:

- (void)drawRect:(NSRect)dirtyRect {


    [[NSColor whiteColor] setFill];
    NSRectFill(dirtyRect);

    [super drawRect:dirtyRect];

    // Drawing code here.
}

我删除了我的旧代码,并通过创建 NSView 子类和我的问题修复。

I remove my old code and use this one for setting background by creating NSView subclass and my issue fix.

这篇关于当NSTableview第二次加载其customcell子视图的更改它的位置如何解决的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 06:46