随着iOS 6的推出,viewDidUnload
和shouldAutorotateToInterfaceOrientation
已被弃用,那么在MonoTouch中应该用什么来替代它们呢?
随着iOS 6的推出,viewDidUnload
和shouldAutorotateToInterfaceOrientation
已被弃用,那么在MonoTouch中应该用什么来替代它们呢?
ViewDidUnload()
方法可以直接删除。如果您在该方法中有代码,则需要将其移动到ViewWillDisappear()
方法中,并将对应的代码移至ViewWillAppear()
方法中。相关的WWDC 2012演讲包括第236集(视图控制器的演变)和第200集(Cocoa Touch的新功能)。
ShouldAutoRotateToInterfaceOrientation()
方法已被SupportedInterfaceOrientations()
取代。请在此处查看:http://dhilipsiva.com/2012/07/25/ios-6-ui-interface-orientation-shouldautorotatetointerfaceorientation-not-working.html
viewDidUnload
iOS6不再调用viewDidUnload
和viewWillUnload
。Xamarin发布的MonoTouch 6版本说明中也提到了这一点,详见苹果文档。
shouldAutorotateToInterfaceOrientation
iOS6引入了两个新方法(在MonoTouch中也可用),可以重写这些方法来实现相同的功能。有关shouldAutorotateToInterfaceOrientation
选择器的更多详细信息,请参见苹果文档。
请注意,shouldAutorotateToInterfaceOrientation
仍然会被调用(虽然已经被弃用并且不鼓励使用,但如果您支持旧版iOS,则仍然可用)。
[Obsolete]
允许C#编译器发出警告(但编译器不知道你的目标是什么)。 iOS 5.1没有改变,因此viewDidUnload
,viewWillUnload
将像以前一样被调用(即它是iOS而不是MonoTouch停止调用它们)。 - poupoushouldAutorotateToInterfaceOrientation
(例如使用respondToSelector
),因此在iOS内部添加第二个检查非常容易(而且便宜)对于苹果来说。有关废弃的更多详细信息,请参见http://stackoverflow.com/q/12786161/220643的答案。 - poupou