我有一个小程序可以在图像井中显示图像。我正在测试,但屏幕上没有任何显示。感谢任何人都可以提供帮助。
.h 文件:
#import <Cocoa/Cocoa.h>
@interface TestAppDelegate : NSObject <NSApplicationDelegate>
{
IBOutlet NSImageView *myImageView;
}
@property (assign) IBOutlet NSWindow *window;
@property (assign) IBOutlet NSImageView *myImageView;
@end
.m 文件:
#import "TestAppDelegate.h"
@implementation TestAppDelegate
- (void)dealloc
{
[super dealloc];
}
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
NSString * filePath = @"haha.png"; // the pic file that I added into the project
NSImage * aImage = [NSImage imageNamed:filePath];
if(aImage)
{
NSLog(aImage.name);
NSLog(@"size %f %f",aImage.size.width,aImage.size.height);
//both of the NSLogs work but the Image-well shows blank
[myImageView setImage:aImage];
}
}
@end