开发者

Create subview on awakeFromNib

I'm trying to create a NSImageView programmatically as a subview of another NSImageView when awakeFromNib is called. My code is as follows (Fader is de开发者_JAVA百科fined in MyImageView.h):

@implementation MyImageView

- (void)awakeFromNib {

Fader = [NSImageView initWithFrame: [self frame]];

}

I get the warning message "NSImageView may not respong to +initWithFrame". When I build, the app simply frizzes without showing anything, and I have to "force quit".

What am I doing wrong?


You’ve forgotten to send +alloc in order to allocate the object. Change that line to:

Fader = [[NSImageView alloc] initWithFrame: [self frame]];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜