且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

删除基于标记的UIView子视图?

更新时间:2023-10-24 21:21:16

问题是你可能只删除了几个视图吗?试试这个:

Is the issue that you're possibly only removing one view of several? Try this:

UIView *removeView;
while((removeView = [self.view viewWithTag:999]) != nil) {
    [removeView removeFromSuperview];
}

如果只有一个视图被创建/标记/删除,你也可以考虑只是添加一个属性来跟踪该视图,并写下:

If there's only one view that's getting created/tagged/removed, you also might consider just adding a property to track that view, and writing:

[self.subView removeFromSuperview];
self.subView = qty;