
它的UItouch保留了我的视图参考而不是释放它.我怎样才能解决这个问题?
这是我的近距离行动的代码:
- (IBAction)closepressed:(UIbutton *)sender { NSLog(@"Close pressed"); if (self.loader) [self.loader cancelJsonLoading]; [self.plVIEw quit]; [self dismissVIEwControllerAnimated:YES completion:nil];}解决方法 你试着打电话: [self.vIEw resignFirstResponder];
这应取消所有待处理的UItouches.
如果这不起作用,您可以跟踪您的触摸:
>定义存储当前触摸的NSMutableSet:
NSMutableSet * _currenttouches;
>在你的init()中:
_currenttouches = [[NSMutableSet alloc] init];
并实施:
- (voID)touchesBegan:(NSSet<UItouch *> *)touches withEvent:(UIEvent *)event { [super.touchesBegan:touches withEvent:event]; [_currenttouches unionSet:touches]; // record new touches}- (voID)touchesEnded:(NSSet<UItouch *> *)touches withEvent:(UIEvent *)event { [super.touchesEnded:touches withEvent:event]; [_currenttouches minusSet:touches]; // remove ended touches}- (voID)touchesCancelled:(NSSet<UItouch *> *)touches withEvent:(UIEvent *)event { [super.touchesEnded:touches withEvent:event]; [_currenttouches minusSet:touches]; // remove cancelled touches} 然后,当您需要清理触摸时(例如,当您释放视图时):
- (voID)cleanCurrenttouches { self touchesCancelled:_currenttouches withEvent:nil]; _currenttouchesremoveAllObjects];} 我认为,它有点Hacky,但是医生说:
总结When an object receives a touchesCancelled:withEvent: message it should clean up any state information that was established in its touchesBegan:withEvent: implementation.
以上是内存溢出为你收集整理的ios – UITouch不释放视图全部内容,希望文章能够帮你解决ios – UITouch不释放视图所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)