I have added a UIWebview to the cell's content view
UIWebView *webview = [UIWebView alloc]init];
[cell.contentView addSubview:webview];
Now I intend to remove 'webview' from the cell's contentview.
Can I do the following?
Method 1:
[webview removeFromSuperview];
Or do I really need to loop through all the subviews of the contentview before removing it?
Method 2:
for (UIView *subview in [self.contentView subviews])
{
if ([subview isKindOfClass:[UIWebView class]])
{
[subview removeFromSuperview];
}
}
I tried method 1 and it didn't seem to work, am not sure if I am missing something or if method 2 is the only way to go
Copyright Notice:Content Author:「Zhen」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/7334791/how-to-remove-a-subview-from-a-cells-content-view