setImage:
セルの画像をセットします
-(void)setImage:(NSImage *)image:
解説
セルの画像をセットします。セルが画像タイプセルでなければ、画像タイプセルに切り替えます。nilをセットして、セルが画像タイプセルなら、現在の画像は破棄されます。
返り値
( void )
なし
引数
( NSImage * )image
画像
フレームワーク
ApplicationKit
クラス
NSCell
Instance Methods
使用可能
10.0
参照
- image
例文
/* @interface MyObject : NSObject { IBOutlet id but;//ボタン IBOutlet id image;//画像 IBOutlet id info;//テキストフィールド IBOutlet id bCell1;//ボタンセル IBOutlet id bCell2;//ボタンセル } - (IBAction)myAction:(id)sender; */ #import "MyObject.h" @implementation MyObject - (IBAction)myAction:(id)sender { //開けるファイル拡張子の配列 NSArray *imgTypes = [ NSArray arrayWithObject : @"tiff" ]; //OpenPanelを作る NSOpenPanel *opImage = [ NSOpenPanel openPanel ]; //Imageを作る NSImage *img; //OpenPanelの結果のボタン番号 int opRet; //OpenPanelでファイル選択 opRet = [ opImage runModalForDirectory : NSHomeDirectory() //どこのディレクトリを出すか file : @"Pictures" //どのどのファイルを選択しておくか types : imgTypes ];//選べるファイルタイプ if ( opRet == NSOKButton ) { // OPENPanelのボタンがOKなら //NSImageを作ってファイルから読み込む img = [ [ NSImage alloc ] initWithContentsOfFile: [ opImage filename ] ]; [bCell1 setImage:img]; } } @end