我从其他UIViewController访问UIView时遇到问题。 在我阅读时,您可以通过这种方式轻松访问类中的方法。 从一个名为AViewController的ViewController调用:
ProfileViewController *ChangeAvatar = [[ProfileViewController alloc] init];
[ChangeAvatar ChangingAvatar:image];
所以在我的ProfileViewController中,我有一个在.h / .m中声明的方法,如
-(void)ChangingAvatar:(UIImage *)image {
NSLog(@"Changing AVATAR!"); //This executes so I see it in console
[avatarView removeFromSuperview]; //This code seems not to work
[avatarView setHidden:YES]; //This code seems not to work neither
avatarView.alpha = 0.0f; //This code seems not to work neither
//I tried adding but didn't work. Like:
imgView = [[UIImageView alloc] init];
imgView.frame = CGRectMake(self.view.bounds.size.width/2-100, self.view.bounds.size.height/2-150, 200, 200);
imgView.image = image;
[self.view addSubview:imgView];
[self.view bringSubviewToFront:imgView];
}
所以我的问题是,我怎么可能执行NSLog,但不能删除,隐藏或更改ProfileViewController.view中的alpha?有什么想法吗?