hai iam new one for objective c
and iOS
development
Set the UIImageview
image. try the following code
arrowImgVw is UIImageView Class object
UIImage *image=[[UIImage alloc]init];
image=[UIImage imageNamed:@"return_journey_denoter.png"];
arrowImgVw.image = image;
hey you are wrong in some point use this code for adding an image into UIImageView and display it on iPhone devide
UIImageView *myImage = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 460)];
//Allocating imageView and set its frame.
myImage.image = [UIImage imageNamed:@"return_journey_denoter.png"];
//add image into imageview
[self.view addSubview:myImage];
// add imageview into your viewcontroller's view
只需一行代码即可将图像设置为 imageView
arrowImgVw.image = [UIImage imageNamed:@"return_journey_denoter.png"];
The code you have written
is ok for setting image
, just check the name
for the given image or you can try following code...
UIIImageView *arrowImgVw = [[UIImageView alloc] initWithFrame:CGRectMake(0,0,200,200)]; //just example change the frame as per your need
arrowImgVw.image = [UIImage imageNamed:@"return_journey_denoter"];
If you are trying to access the image from the assets . Use the below code
NSBundle *bundle = [NSBundle bundleForClass:[self class]];
UIImage *image = [UIImage imageNamed:@"image" inBundle:bundle compatibleWithTraitCollection:nil];
UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
image should be inside your assets folder .
In Swift3.0
To set image to your imageView use belwo code.
arrowImgVw.image = UIImage(named: "return_journey_denoter.png")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.