在我点击图像拉相机之前,我想在imageview上设置一个默认图像,该图像显示http://www.inc.com/images/avatar/default1.gif以通知在该图像视图中显示人物图像。如何设置默认图像
什么是做这个程序的最佳方式?
此致敬礼。
在我点击图像拉相机之前,我想在imageview上设置一个默认图像,该图像显示http://www.inc.com/images/avatar/default1.gif以通知在该图像视图中显示人物图像。如何设置默认图像
什么是做这个程序的最佳方式?
此致敬礼。
如果您正在使用一个UIImageView的第一件事就是使用此代码
UIImage *defaultImage = [UIImage imageNamed:@"default.png"];
然后创建一个UIImage对象将其传递给UIImageView的对象,如果它是你的视图控制器的属性,你可以使用这个(ImageView的是的UIImageView的变量名)
self.imageView.image = defaultImage;
如果你在实例化您的视图控制器一个新的UIImageView,你可以使用这个
UIImageView *imageView = [[UIImageView alloc] initWithImage:defaultImage];
UIImageView *theImageView;
//assuming that's the declaration in your header
//make sure default1.gif is inside your application bundle
//copied into the resources folder of your xcode project
//this code goes into your -viewDidLoad method
theImageView.image = [UIImage imageNamed:@"default1.gif"];
感谢您的帮助:) – Bruno
非常感谢:) – Bruno