Bug 21283 - RemoveFromSuperview not removing the correct views
Summary: RemoveFromSuperview not removing the correct views
Alias: None
Product: iOS
Classification: Xamarin
Component: XI runtime ()
Version: 7.9.1.x
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2014-07-12 16:55 UTC by Paul Johnson
Modified: 2014-07-15 12:54 UTC (History)
2 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Paul Johnson 2014-07-12 16:55:38 UTC
I have my main VC View which has on it a pile of things from the IB. On examination of the View, it shows an UIImageView, UIButtons, UILabel, UITabBar and UITabBarItems and a UIScrollView.

If I have the following in my ViewWillAppear, all of these views are removed leaving a completely blank UI whereas only those in the subview that are a UIView should be removed. 

if (View != null)
    foreach(var v in View.Subviews)
       if (v is UIView)

=== Xamarin Studio ===

Version 5.2 (build 366)
Installation UUID: f3d1a29c-1ba2-4a83-a193-1087efe91a85
	Mono 3.6.0 ((no/5ff701f)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 306000037

=== Apple Developer Tools ===

Xcode 6.0 (6233.3)
Build 6A254o

=== Xamarin.Mac ===


=== Xamarin.Android ===

Version: 4.14.0 (Business Edition)
Android SDK: /Users/PFJ/Library/Developer/Xamarin/android-sdk-mac_x86
	Supported Android versions:
		1.6   (API level 4)
		2.1   (API level 7)
		2.2   (API level 8)
		2.3   (API level 10)
		3.1   (API level 12)
		3.2   (API level 13)
		4.0   (API level 14)
		4.0.3 (API level 15)
		4.1   (API level 16)
		4.2   (API level 17)
		4.3   (API level 18)
		4.4   (API level 19)
Java SDK: /usr
java version "1.6.0_65"
Java(TM) SE Runtime Environment (build 1.6.0_65-b14-466.1-11M4716)
Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-466.1, mixed mode)

=== Xamarin.iOS ===

Version: (Business Edition)
Hash: 0ba5e04
Build date: 2014-07-01 17:06:51-0400

=== Build Information ===

Release ID: 502000366
Git revision: 008dc0b6dafb6830285cf4f3335c839c1bf6d388
Build date: 2014-07-08 21:03:17-04
Xamarin addins: e355572fca91feb2168ee4eb47baa2654e6335ad

=== Operating System ===

Mac OS X 10.10.0
Darwin Pauls-iMac.local 14.0.0 Darwin Kernel Version 14.0.0
    Mon Jun 30 11:54:42 PDT 2014
    root:xnu-2782.1.20~3/RELEASE_X86_64 x86_64
Comment 1 Rolf Bjarne Kvinge [MSFT] 2014-07-15 12:54:32 UTC
The construct "v is UIView" evaluates to true as long as v is UIView or a subclass of UIView (which includes all the other classes you list; UIButton, UILabel, UITabBar, etc).

If you only want to remove those v's which are UIView (and nothing else), you must do this instead:

v.GetType () == typeof (UIView)