2016-08-19 3 views
1

Comment charger NSView avec xib dans mon NSViewController? Je veux réutiliser le nsview personnalisé avec xib dans plus de trois nsviewcontroller (emplacement). Comment puis-je charger le xib nsview dans nsviewcontrollerCharger NSView avec xib dans NSViewcontroller

Aidez-moi à résoudre ce problème.

Merci d'avance.

Répondre

0

Essayez ceci:

+ (NSView *)loadWithNibNamed:(NSString *)nibNamed owner:(id)owner class:(Class)loadClass { 

    NSNib * nib = [[NSNib alloc] initWithNibNamed:nibNamed bundle:nil]; 

    NSArray * objects; 
    if (![nib instantiateWithOwner:owner topLevelObjects:&objects]) { 
     NSLog(@"Couldn't load nib named %@", nibNamed); 
     return nil; 
    } 

    for (id object in objects) { 
     if ([object isKindOfClass:loadClass]) { 
      return object; 
     } 
    } 
    return nil; 
} 

de cette repo

+0

Merci @ Marco –