UIImageView无法显示图片的问题

先用NSLog输出UIImage对象,如果为空就说明创建UIImage对象时出现问题,所以就是路径名或者图片格式出现问题,下面这种路径名就有问题:

    NSString *imagePath=[[NSBundle mainBundle]pathForResource:@"school3" ofType:@"png"];
      UIImage *image=[UIImage imageWithContentsOfFile:imagePath];
    NSLog(@"%@",image);
    self.imageView.image=image;


所以图片无法显示,应改成:

    NSString *imagePath=[[NSBundle mainBundle]pathForResource:@"school_3" ofType:@"png"];



你可能感兴趣的:(iOS基础)