I made a CustomView that extends NSView. And a class MyCLass that contains a CustomView. In below code CustomView viewA is showing correctly. But that same view through MyClass wont show. I got no error but there is nothing on the screen. Anybody knows why?
CustomView* viewA = [[CustomView alloc]initWithFrame:NSMakeRect(0, 0, 600, 400)];
MyClass *foo;
[foo setFooView:[[CustomView alloc]initWithFrame:NSMakeRect(0, 0, 600, 400)]];
// or [foo setFooView:viewA];
[[self.window contentView] addSubview:viewA]; //IS SHOWING
[[self.window contentView] addSubview:foo.fooview]; //DOES NOT SHOW?
.h file of MyClass
#import "CustomView.h"
@interface MyClass : NSObject
{
CustomView *fooview;
}
-(CustomView *) fooview;
-(void) setFooView:(CustomView *)input;
@end
.m file of MyClass
#import "MyClass.h"
@implementation MyClass
- (CustomView *)fooview {
return fooview;
}
-(void) setFooView:(CustomView *)input
{
fooview = input;
}
@end
Are you actually creating an instance of MyClass
anywhere? It appears as if you're putting the CustomView
into a nil object.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.