Now that viewDidUnload
and shouldAutorotateToInterfaceOrientation
have been deprecated with iOS 6, what should we replace them with in MonoTouch?

- 43,413
- 6
- 77
- 174

- 6,682
- 6
- 61
- 106
2 Answers
ViewDidUnload()
you can just remove. If you have code in there, you'll have to move it into ViewWillDisappear() and the counterpart into ViewWillAppear()
. Relevant talks from WWDC 2012 are episode 236 (The evolution of view controllers) and 200 (What's new in Cocoa Touch).
ShouldAutoRotateToInterfaceOrientation()
is replaced by SupportedInterfaceOrientations().
See here: http://dhilipsiva.com/2012/07/25/ios-6-ui-interface-orientation-shouldautorotatetointerfaceorientation-not-working.html

- 3,688
- 1
- 24
- 35

- 32,180
- 27
- 124
- 263
viewDidUnload
Both viewDidUnload
and viewWillUnload
are not called anymore by iOS6. Xamarin's release notes for MonoTouch 6 covers this as well as Apple documentation.
shouldAutorotateToInterfaceOrientation
Two new methods (in iOS6, available in MonoTouch) can be overridden to get the same result.
See Apple documentation for the shouldAutorotateToInterfaceOrientation
selector for more details.
Note that shouldAutorotateToInterfaceOrientation
is still called (it's deprecated and discouraged for future use, but still available if you support older version of iOS).

- 43,413
- 6
- 77
- 174
-
If i'm targeting version 5.1 why am I still getting these warnings? If the device is running 5.1, will the methods be called? – Jonas Stawski Sep 20 '12 at 19:26
-
Because MonoTouch 6 is *in sync* with iOS6 API and `[Obsolete]` allows the C# compiler to issue warnings (but the compiler does not what you're targeting). iOS 5.1 is unchanged so the `viewDidUnload`, `viewWillUnload` will be called like they were before (i.e. it's iOS, not MonoTouch, that stops calling them). – poupou Sep 20 '12 at 19:32
-
Does this mean that there is one set of methods (or checks) being issued in iOS 6 and a completely different set in older versions? I understand that this rotation system is now going by the information in the plist and the SupportedInterfaceOrientations method, but is this method supported, and called, in older versions? I doubt every user of our apps will upgrade to iOS 6 so a clearer image of what I'm expected to do with these obsolete warnings would be welcome. For the moment I'm just ignoring them but I hardly say that is safe either. – Lasse V. Karlsen Oct 10 '12 at 17:02
-
@LasseV.Karlsen neither I or Xamarin have access to iOS code. OTOH Apple already has to check if you override/implement `shouldAutorotateToInterfaceOrientation` (e.g. using `respondToSelector`) so adding a 2nd check, inside iOS, is pretty easy (and cheap) for Apple. More details on deprecation was given in the answer to http://stackoverflow.com/q/12786161/220643 – poupou Oct 10 '12 at 17:45