gpt4 book ai didi

ios - 如何在 iOS 中释放或隐藏 UIImageView?隐藏不起作用

转载 作者:行者123 更新时间:2023-11-28 21:42:57 30 4
gpt4 key购买 nike

我的目的是当我拖动一个对象时,一个小的UIImageView 显示,当触摸结束时,UIImageView 被释放。

- (IBAction)TLMove:(UIPanGestureRecognizer *)sender {

//add UIImage view to show the scaled dot
UIImageView *scaleUPView = [[UIImageView alloc] initWithFrame:CGRectMake(200, 30, 100, 100)] ;
scaleUPView.layer.zPosition = 300 ;
[scaleUPView setImage:self.OriginImage] ;
[self.view addSubview:scaleUPView] ;

self.TopLeftPoint.center = [sender locationInView:self.TopLeftPoint.superview] ;

targetTL = self.TopLeftPoint.center ;

if (sender.state == UIGestureRecognizerStateEnded || sender.state == UIGestureRecognizerStateCancelled || sender.state == UIGestureRecognizerStateFailed)
{
[scaleUPView setHidden:YES] ; // not working still shows
[scaleUPView removeFromSuperview] ; //not working still shows
}
}

但这根本不起作用,我尝试了 scaleUPView.hidden =YES,仍然不起作用。 scaleUPView 将始终显示,我希望它在 ARC 模式下释放,我无法在启用引用计数时释放它。

最佳答案

你可以设置alpha = 0。你必须检查 if 语句中的 ure。

所以你的代码可能是这样的:

if (sender.state == UIGestureRecognizerStateEnded || sender.state == UIGestureRecognizerStateCancelled || sender.state == UIGestureRecognizerStateFailed)
{
NSLog(@"inside if statement"); \\
[scaleUPView setAlpha:0] ;
[scaleUPView removeFromSuperview] ;
}

希望这对您有所帮助。

关于ios - 如何在 iOS 中释放或隐藏 UIImageView?隐藏不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31353937/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com