gpt4 book ai didi

iphone - 查看基于 iPhone 应用程序 subview 删除?

转载 作者:行者123 更新时间:2023-11-28 23:08:56 28 4
gpt4 key购买 nike

我有麻烦了。

我正在添加其他类似的 View 。

haberdetay *detayview = [[haberdetay alloc] initWithNibName:@"haberdetay" bundle:nil];

CATransition *transition = [CATransition animation];
transition.duration = 0.25;
transition.type = kCATransitionPush;
transition.subtype = kCATransitionFromRight;
[self.view.layer addAnimation:transition forKey:nil];

[self.view addSubview:detayview.view];

这个 View 打开了另一个 View ,另一个可能。然后用户触摸主图标。这所有的 View 都在使用内存。我怎样才能删除它们。我在努力

NSArray * subviews = [self.view subviews];
for(UIView * aSubview in subviews)
{
// this removes and releases the subviews you allocated
[aSubview removeFromSuperview];
}

这会访问 haberdetay 的 subview ,但我必须访问所有 subview 才能删除或访问它们。

如你所知,我很困惑 :) 如果你理解我的意思,请告诉我,我该怎么做? :)

最佳答案

您应该使用 pushViewController 或 presentModalViewController,而不是在另一个 Viewcontroller 中添加一个 Viewcontroller 的 View ,当您想要返回时,您可以使用 popViewController 或 dismissModalViewController,这也有助于内存管理。

关于iphone - 查看基于 iPhone 应用程序 subview 删除?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8730957/

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