开发者

Cannot create NSImageView through Interface Builder in Xcode 4

开发者 https://www.devze.com 2023-04-11 06:07 出处:网络
I have found several tutorials describing the possibility to add an NSImageView with Interface Builder just like you can add an UIImageView in iOS.

I have found several tutorials describing the possibility to add an NSImageView with Interface Builder just like you can add an UIImageView in iOS.

However, in Xcode 4.1 the control doesn't seem to exist. I can create NSImageView's programmatically but it's not very practical f开发者_高级运维or very graphical interfaces. I have something called IKImageView but with it I cannot set the image content through interface builder.

Can I get the NSImageView to appear in Interface Builder somehow?

Thanks.


Look for the Image Well control in the Object Library - the underlying class for Image Well is NSImageView.

BTW - if you type in the search bar below the Object Library it will give you matches based on the classes which back the controls as well as on the names of the controls. If you're only scrolling through the Object Library you can easily miss the class names.


A second mechanism for creating an NSImageView is to drag an image directly out of the media library to some containing view in your canvas. Most places where you drop it will result in an NSImageView being created to host the image.


The common way is to use a custom view for IB stuff, and programmatically have it contain an NSImageView (possibly with the same frame if you don't want to add other stuff). Custom view is just an empty view to contain basic frame/structure information.

Create your own class (subclassing NSView) containing an NSImageView, and in IB set your custom view's class to your custom class. Now you can make changes programmatically or through IB.

0

精彩评论

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

关注公众号