在我點擊圖像拉相機之前,我想在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