简体   繁体   English

如何在touchesEnded中释放self(UIImageView)?

[英]How do I release self (UIImageView) in touchesEnded?

I have an object that is a child of UIImageView. 我有一个对象是UIImageView的子级。 Before all these touches methods, I add this object to the superview and then user moves it. 在所有这些touchs方法之前,我将此对象添加到父视图中,然后用户将其移动。 In touchesEnded, sometimes I want to release self. 结束语,有时候我想释放自我。 I've tried: 我试过了:

- [self release]

or 要么

- [self removeFromSuperview]

But all these tries end up in exceptions. 但是所有这些尝试都以例外结束。 What's the right way to release self? 释放自我的正确方法是什么?

You cannot release self. 你不能释放自我。 self is main view and if you want to remove object from UIImageView then you have to remove it using that object name. self是主视图,如果要从UIImageView中删除对象,则必须使用该对象名称将其删除。 [objNameSubViewOFUIImageView removeFromSuperview]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM