Hide preview with tag

In swift I can show the tag

  let MY_CUSTOM_TAG = 123
  tableView.tag = MY_CUSTOM_TAG

My question is: how do I remove a view from a supervisor using a tag using swift?

Goal C:

#define MY_CUSTOM_TAG 1234
mySubview.tag = MY_CUSTOM_TAG;
[self.tableView addSubview:mySubview] ;

//remove view with tag

[[self.tableView viewWithTag:MY_CUSTOM_TAG]removeFromSuperview] ;
+4
source share
2 answers

Similarly, with Objective-C it just has a different syntax;

view.viewWithTag(tag).removeFromSuperview()
+10
source

For those who came here to look for a solution to hide the preview.

Objective-C:

[[self.view viewWithTag:MY_CUSTOM_TAG] setHidden: YES];

Swift:

self.view.viewWithTag(viewWithTag:MY_CUSTOM_TAG)?.hidden = true

PD: because the title asks how to hide under the view, and not how to remove it.

+2
source

Source: https://habr.com/ru/post/1548125/


All Articles