我正在尝试使用属性从另一个ViewController设置图像。但它不起作用。有人说你只能从班级内部改变图像。但我试过,它的工作无论如何都没有。有什么想法吗?
//viewcontroller1
ViewController *viewcont = [[ViewController alloc]initWithNibName:@"ViewController" bundle:nil];
[self presentViewController:viewcont animated:NO completion:nil];
[viewcont somemethodThatIscallemFromOutside];
//viewcontroller2
-(void)somemethodThatIscallemFromOutside{
if (!r12 && g12 && !b12) {
green.image = [UIImage imageNamed:@"Green"];
self.Greenscore.textColor = [UIColor greenColor];
self.readyplayer2.image = [UIImage imageNamed:@"Greenready"];
}
}
答案 0 :(得分:0)
首先没有这样的方法
[UIImage imagename:@"Image1.png"]
替换为
[UIImage imageNamed:@"Image1.png"];
你应该看到myimageview
是否被侵犯了?
答案 1 :(得分:0)
试试这个:
myimageview.image = [UIImage imageNamed:@"Image1.png"];
希望这会有所帮助.. :)
答案 2 :(得分:-1)
将此替换为您的代码,将您的错误改为“_”,即“=”
[myimageview setImage:[UIImage imageNamed:@"Image1.png"]];