Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/115.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在iPhone的UIImageView中显示图像_Iphone_Ios_Image - Fatal编程技术网

在iPhone的UIImageView中显示图像

在iPhone的UIImageView中显示图像,iphone,ios,image,Iphone,Ios,Image,我不想使用选择器视图来拾取图像。我有iPhone图像库中的图像名abc.JPG,我可以通过编程获取此图像并打开UIImageView UIImageView *myImage = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 460)]; myImage.image = [UIImage imageNamed:@"abc.JPG"]; [self.view addSubview:myImage]; 或者,如果您已经拥

我不想使用选择器视图来拾取图像。我有iPhone图像库中的图像名
abc.JPG
,我可以通过编程获取此图像并打开
UIImageView

   UIImageView *myImage = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 460)];

myImage.image = [UIImage imageNamed:@"abc.JPG"];

[self.view addSubview:myImage];
或者,如果您已经拥有名为myImage的uiimageview,则只需写下:

myImage.image = [UIImage imageNamed:@"abc.JPG"];
也许:

试着跟随教程


即使您不想,我认为您也必须使用
UIImagePickerViewController
来拾取图像,否则,将从项目中的资源中拾取图像。

如果图像不在应用程序资源中,并且您不想使用UIImagePickerController,则可以使用AlassetLibrary获取用户相册或相机卷上的图像

请看这里:

致编辑我文章的那位先生:如果我想发布
UIImageView
,我会的。为简单起见,我假设op使用ARC。对于-1的人,至少要有常识来解释原因。谢谢你的回复。我的图像不在我的应用程序资源文件夹中。图像显示在模拟器库中。至少在iOS 6中,这种方法实际上被称为
imagename:
。据我所知,我们无法在iPhone/iPad相册应用程序中为图像命名。你能详细说明你的问题陈述吗?见。谢谢你的回复。我的图像不在我的应用程序资源文件夹中。图像显示在模拟器库中。这段代码可以正常工作吗
UIImageView *myImageView = [UIImageView alloc] init];
myImageView.image = [UIImage imageNamed:@"abc.JPG"];