0

view1.h文件

@property(nonatomic,strong) NSView  *aboutView;

view1.m文件中创建了 NSView

aboutView = [[NSView alloc]initWithFrame:NSMakeRect(6, 6, width -12, height -29)];
[aboutView setHidden:YES];
[view addSubview:aboutView];


NSImageView *imgl=[[NSImageView alloc]initWithFrame:NSMakeRect(0, 0, width -12, height -29)];
[imgl setImageAlignment:NSImageAlignBottomLeft];
[imgl setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
[imgl setImageScaling:NSImageScaleAxesIndependently];
[imgl setImage:[NSImage imageNamed:@"yuan"]];
[aboutView addSubview:imgl];

ButtonController.m 中的NSView如何找到和隐藏 NSView ?

-(void)mouseUp:(NSEvent *)theEvent{
    NSView *aboutView = [(view1 *)self.superview.window aboutView];
    [aboutView setHidden:NO];
}
4

1 回答 1

1

怎么样

-(void)mouseUp:(NSEvent *)theEvent{
    view1 *viewObj=(view1 *)self.superview.window;
    NSView *aboutView = [viewObj aboutView];
    [aboutView setHidden:YES];
}
于 2013-04-18T09:18:29.230 回答