Re: Trying to display a static image on my window. Any tips would be great
Re: Trying to display a static image on my window. Any tips would be great
- Subject: Re: Trying to display a static image on my window. Any tips would be great
- From: Steve Christensen <email@hidden>
- Date: Tue, 01 Jul 2008 09:38:39 -0700
If you add an IBAction method to your window controller's class, it
can respond to a click on the image by calling
[[NSWorkspace sharedWorkspace] openURL:@"http://www.apple.com"];
On Jul 1, 2008, at 9:09 AM, Papa-Raboon wrote:
Thanks loads for that Steve. It seems to be doing as I wanted now.
Someone kindly pointed out that if I created my image with an Alpha
chanel that it could also have transparencies too which worked
beautifully. I just need to figure out how to hyperlink it so it can
open a URL in a browser now.
Cheers
Paul
2008/7/1 Steve Christensen <email@hidden>:
On Jul 1, 2008, at 6:41 AM, Papa-Raboon wrote:
I have been trying to get a static image to display in a corner
of my
window and it has to literally just sit there and do nothing
however I
have searched and searched Apple's dodumentation but no success yet.
I have dropped an Image View onto the window in IB and set the
following in my .h file in Xcode:
IBOutlet NSImageView *theImage;
Then in my .m file I have this so far:
NSString *imageName;
NSImage *tempImage;
imageName = [[NSBundle mainBundle] pathForResource:@"logo"
ofType:@"PNG"];
tempImage = [[NSImage alloc]
initWithContentsOfFile:imageName];
My image is set in my project in the resources folder and is called
logo.png and I hooked up the object to the NSImageView using IB.
Can't seem to get it to display. I believe I have a line of code
missing that will tie my MSImage to my NSImageView but not sure how.
Any Ideas please?
I'm pretty new to cocoa and don't understand all the lingo yet so be
gentle please.
This is just a static image from your application's bundle, so you
should be
able to do everything in IB without writing any code. After
dragging a
NSImageView into your window, open the Inspector window if it's
not already
open. Then set attributes Image=logo (Cocoa will figure out the
file's
extension), Border=none, Scale: to fit. Select Size from the
inspector's
popup menu and set the size to the image's size. Depending on
where the
image will be in your window, you may need to set the autosizing
struts and
springs right below the size info. You can find out if it stays in
the
correct place when your window resizes by selecting Test Interface
from the
File menu (command-R).
steve
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden