添加 NSButton 作为 IKImageFlowView 的子视图
我在我的应用程序中使用 IKImageFlowView 并需要在其上添加一个 nsbutton,
我使用下面给出的代码,
在我的 .h 文件中 IBOutlet id browserView;
在 nib 中添加了一个自定义视图并将其类更改为 myImageFlowView ,因为我从 IKImageFlowView 子类化为
@interface myImageFlowView : IKImageFlowView
,在我的 appController 类中,我尝试使用以下代码片段将按钮添加到 browserView ,
NSRect initialFrame = NSMakeRect(20.0, 50.0, 100.0, 100.0);
NSButton *myBtn = [[NSButton alloc] init];
[myBtn setFrame:initialFrame];
[myBtn setBordered:NO];
[myBtn setAutoresizesSubviews:TRUE];
[myBtn.cell setImageScaling:NSImageScaleAxesIndependently];
[myBtn setImage:[NSImage imageNamed:@"AppleColor.png"]];
[browserView addSubview:myBtn];
我无法添加此按钮作为 IKImageFlowView 的子视图,我可以向 NSView 添加按钮。 我做错了什么。请帮助。
I am using IKImageFlowView in my application and need to add a nsbutton over it,
I am using the code as given below,
In my .h file
IBOutlet id browserView;
in nib added a custom view and changed its class as myImageFlowView as I am subclassing from IKImageFlowView as
@interface myImageFlowView : IKImageFlowView
and in my appController class I am trying to add button to browserView with following code snippet,
NSRect initialFrame = NSMakeRect(20.0, 50.0, 100.0, 100.0);
NSButton *myBtn = [[NSButton alloc] init];
[myBtn setFrame:initialFrame];
[myBtn setBordered:NO];
[myBtn setAutoresizesSubviews:TRUE];
[myBtn.cell setImageScaling:NSImageScaleAxesIndependently];
[myBtn setImage:[NSImage imageNamed:@"AppleColor.png"]];
[browserView addSubview:myBtn];
I am not able to add this button as a subview to IKImageFlowView,I can add button to NSView.
What I am doing wrong.Please help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论