-2

OSX 10.7.5 - XCode 4.6.1 - application OSX, not iOS. Code very simple.
A Window > contentWiew > subView with ViewController > Button. The button is created using ViewController.xib.

All displays as expected, but when I click on the button, all fails. All Objects are not nil.

ViewController *viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
NSView *aView = [NSView new];
aView = [viewController view];
[[_window contentView] addSubview:aView];

In Console :

[NSContentSizeLayoutConstraint buttonAct:]: unrecognized selector sent to instance 0x1061178a0
Mike D
  • 4,938
  • 6
  • 43
  • 99

1 Answers1

0

You create a view controller which has a view associated with it. You create a new NSView. You overwrite your newly created NSView with the view controller's view. Finally, you add a reference to the view controller's view to the window's content view.

//this does the same as your above code
ViewController *viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
//in ios, you typically don't add things straight to the window
[[_window contentView] addSubview:viewController.view];

This is saything that buttonAct: isn't class method for NSContentSizeLayoutConstraint.

[NSContentSizeLayoutConstraint buttonAct:]: unrecognized selector sent to instance 0x1061178a0
JeffRegan
  • 1,322
  • 9
  • 25