Ios 如果Imageview上没有图像,则Xcode显示图像
我需要帮忙做这样的东西Ios 如果Imageview上没有图像,则Xcode显示图像,ios,objective-c,if-statement,nsuserdefaults,Ios,Objective C,If Statement,Nsuserdefaults,我需要帮忙做这样的东西 IBOutlet UIImageView *imageview; IBOutlet UIImageView *imageview2; if(imageview have no image){ SET this image @"x"; }else if(imageview2 have no image){ Set this Image @"x"; } 并使用NSUserDefaults保存和加载代码 UIImageView *myImageView; if(myIm
IBOutlet UIImageView *imageview;
IBOutlet UIImageView *imageview2;
if(imageview have no image){
SET this image @"x";
}else if(imageview2 have no image){
Set this Image @"x";
}
并使用NSUserDefaults保存和加载代码
UIImageView *myImageView;
if(myImageView.image){
myImageView.image = [UIImage imageNamed:@"myImage1"];
//image exists
}
else {
myImageView.image = [UIImage imageNamed:@"myOtherImage"];
//image doesnt exists
}
//by this time some image or the other will be set so we save the image
[[NSUserDefaults standardDefaults]setObject:myImageView.image forKey:@"myImage"];
我不知道NSUserDefault是否可以设置图像对象,因为我没有尝试过,您可能会遇到异常,最好使用[[NSUserDefaults standardDefaults]setObject:@ImageNameOfimage forKey:@myImageName]将图像的名称保存在if语句中你应该考虑阅读一本书或者浏览一些苹果公司提供的开发者指南。别为此生气。这是所有你应该知道的基本编程,花15-20分钟研究手头的主题。或者,如果你尝试过一些东西,请编辑你的问题,将你尝试过的东西包括在内。你想达到什么目的?你得到了什么错误?:谢谢,但是你能帮我处理NSUserDefaults吗?这样我就可以保存和加载了。请不要知道我没有这样做。我不能这样做。我必须有15分钟的时间来思考