views:

22

answers:

1

I have this code to load an NSView from a NIB and add it to another NSView:

// INIT
- (void)awakeFromNib {
  // Load nib
  DNListViewController *listViewController = [[DNListViewController alloc] initWithNibName:@"ListView" bundle:nil];

  // Add view to window
  [listViewController.view setFrame:detailView.frame];
  [detailView addSubview:listViewController.view];

  // MEM
  [listViewController release];
}

All outlets are connected right, but nothing shows up. I don't understand why! Can someone help me? Thanks.


This is about NSViews, not UIViews!

+1  A: 

Oh, I fixed it already. Nevermind, I'll let is stay here for people from the future.

[listViewController.view setFrame:detailView.frame];

must be

[listViewController.view setFrame:detailView.bounds];
Time Machine
Specifically, a view's bounds are in its own co-ordinate space, whereas its frame is in its parent view's co-ordinate space. As such, you need to define the list view's frame in the co-ordinate space of the detail view (by getting the detail view's bounds), not the co-ordinate space of the detail view's parent view (the detail view's frame).
Peter Hosey