我有一个小代码来显示图像 1 并在 2 秒后将 image1 替换为 image2 并带有下面的动画
UIImageView *view1 = [[UIImageView alloc] initWithFrame:CGRectMake(0, 410, 1020, 400)];
UIImage *image = [UIImage imageNamed:@"img.jpeg"];
view1.image = image;
[self.view addSubview:view1];
UIImageView *view2 = [[UIImageView alloc] init ];
view2.frame = CGRectMake(0, 410, 0, 400);
view2.image = [UIImage imageNamed:@"bien.jpeg"];
[self.view addSubview:view2];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.8];
[UIView setAnimationDelay:2];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(removeView: view1:)];
view2.frame = CGRectMake(0, 410, 800, 400);
[UIView commitAnimations];
和函数 removeView 从下面的超级视图中删除 view1:
-(void)removeView: (UIImageView *)view1{
[view1 removeFromSuperview];
}
所以我不知道为什么我从superview中删除view1的功能不起作用,请帮助我!非常感谢...