1

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.

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.

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.

enter image description here

Nitin Gohel
  • 49,482
  • 17
  • 105
  • 144
  • Are you using auto layout? If so, you need to show or describe the constraints on the affected views. Are you setting up the cell view in your table view delegate's `-tableView:viewForTableColumn:row:` method? If so, you need to show that code. – Ken Thomases May 13 '15 at 11:29
  • @KenThomases thanks for look in my issue i just fix this by following my answer. :) – Nitin Gohel May 13 '15 at 11:59

1 Answers1

0

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.

enter image description here

And set background color in viewForTableColumn like:

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

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.

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.

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.
}

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

Nitin Gohel
  • 49,482
  • 17
  • 105
  • 144