
这就是我所拥有的,它成功地从self.vIEw中删除了视图,但它没有将它添加到self.contentVIEw
for (UIVIEw *vIEw in self.vIEw.subvIEws) { if (vIEw.tag != 666) { [vIEw removeFromSupervIEw]; [self.contentVIEw addSubvIEw:vIEw]; }} 任何帮助,将不胜感激.
解决方法 代码中的问题是,当您调用removeFromSupervIEw时,父视图将释放该视图.无需调用removeFromSupervIEw,只需将其添加为另一个视图的子视图,将其从当前的parentVIEw中删除.所以使用:
for (UIVIEw *vIEw in self.vIEw.subvIEws){ if (vIEw.tag != 666) { [self.contentVIEw addSubvIEw:vIEw]; }} 根据UIView Class Reference:
总结addSubvIEw:
Adds a vIEw to the end of the receiver’s List of subvIEws.
- (voID)addSubvIEw:(UIVIEw *)vIEwParameters
vIEw
06001
discussion
This method retains vIEw and sets its next responder to the receiver,
which is its new supervIEw.VIEws can have only one supervIEw. If vIEw already has a supervIEw and that vIEw is not the receiver,this method removes the prevIoUs supervIEw before making the receiver its new supervIEw.
以上是内存溢出为你收集整理的ios – 从一个视图中删除视图并将其添加到另一个视图中全部内容,希望文章能够帮你解决ios – 从一个视图中删除视图并将其添加到另一个视图中所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)