在图像中显示图像

时间:2012-09-02 16:02:49

标签: image

我是初学者,试图在图像井或按钮中尝试显示图像,位图和tiff,但没有成功。代码如下。它运行但没有显示任何内容。我尝试了两种方法来定义字符串,也使用self.well或_well,但没有任何作用。如果我尝试使用[well1 setImage:testImage];如其他示例中所示,我收到错误“使用未声明的标识符。

//代码

  NSString *inFilePath = @"/Documents/Track1bmp.bmp";
  NSImage *testImage = [[NSImage alloc] initWithContentsOfFile:inFilePath];
   //well1 is your outlet
  [self.well1 setImage:testImage];
  [self.butt1 setImage:testImage];
  [_well2 setImage:testImage];

// Also trying this

  NSString* imageName = [[NSBundle mainBundle]
                       pathForResource:@"/Applications/Sudoku4/Pinktiff" ofType:@"TIFF"];
  NSImage* tempImage = [[NSImage alloc] initWithContentsOfFile:imageName];
  [self.well1 setImage:tempImage];

0 个答案:

没有答案