我需要帮助来制作这样的东西
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
答案 0 :(得分:-1)
试试这个
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:@"imagenameoftheimage" forKey:@"myImageName]"