macOS/iOS API解説

iOS , Mac アプリケーション開発のために使われる主要フレームワークの日本語情報です。2010年代に書かれた内容です。今後更新はありません。

目次

initImageCell:

画像セルを初期化して返します
-(id)initImageCell:(NSImage *)anImage:

解説

画像セルを初期化して返します。
画像(anImage)がnilなら画像はセットされません。

返り値

( id )

NSCellオブジェクト

引数

( NSImage * )anImage

セットする画像

フレームワーク

ApplicationKit

クラス

NSCell

Instance Methods

使用可能

10.0

参照

例文

/* @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 initImageCell:img];
}
}

@end