我正在显示一个视图,其中有一个按钮。单击此按钮时,我将通过 Objective C 中定义的动画方法显示 PopUp 视图,并在 Popup 视图上添加图像。然后在视图上的任何点击此弹出视图通过将其宽度和高度设置为零来隐藏,但它上面的图像没有隐藏。我该如何隐藏它..?这些是我正在使用的方法..
单击按钮后调用此方法..
-(void)btnImageClkForPopUp:(id)sender
{
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:2.5];
popup_viewforimage.frame=CGRectMake(8, 30, 300, 250);
popup_viewforimage.backgroundColor=[UIColor whiteColor];
UIImageView *imgview=[[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 300, 250)];
imgview.image=[UIImage imageNamed:@"apple.jpeg"];
[popup_viewforimage addSubview:imgview];
[self.view addSubview:popup_viewforimage];
[UIView commitAnimations];
}
在点击视图后调用这两种方法来隐藏它
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
{
if ([touch.view isKindOfClass:[UIButton class]])
{
return NO;
}
return YES;
}
-(void)hidekeyboard
{
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:2.5];
popup_viewforimage.frame= CGRectMake(15, 65, 0, 0);
popup_viewforimage.backgroundColor=[UIColor grayColor];
[self.view addSubview:popup_viewforimage];
[UIView commitAnimations];
}