using System; using System.Drawing; using Foundation; using UIKit; using WebKit; namespace HDL_ON_iOS { public class ViewControllerBase : Shared.BaseViewController { //public override bool ShouldAutorotateToInterfaceOrientation (UIInterfaceOrientation toInterfaceOrientation) //{ // return false; //} NSObject _keyboardObserverWillShow; NSObject _keyboardObserverWillHide; //public override bool ShouldAutorotate () //{ // return false; //} //public override UIInterfaceOrientationMask GetSupportedInterfaceOrientations () //{ // if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad) { // UIApplication.SharedApplication.SetStatusBarOrientation (UIInterfaceOrientation.LandscapeRight, false); // return UIInterfaceOrientationMask.LandscapeRight; // } else { // return UIInterfaceOrientationMask.Portrait; // } //} public override void ViewDidLoad() { base.ViewDidLoad(); //设置键盘事件处理程序 RegisterForKeyboardNotifications(); } protected virtual void RegisterForKeyboardNotifications() { _keyboardObserverWillShow = NSNotificationCenter.DefaultCenter.AddObserver (UIKeyboard.WillShowNotification, KeyboardWillShowNotification); _keyboardObserverWillHide = NSNotificationCenter.DefaultCenter.AddObserver (UIKeyboard.WillHideNotification, KeyboardWillHideNotification); } protected virtual void UnregisterKeyboardNotifications() { NSNotificationCenter.DefaultCenter.RemoveObserver(_keyboardObserverWillShow); NSNotificationCenter.DefaultCenter.RemoveObserver(_keyboardObserverWillHide); } protected virtual UIView KeyboardGetActiveView() { return this.View.FindFirstResponder(); } protected virtual void KeyboardWillShowNotification(NSNotification notification) { UIView activeView = KeyboardGetActiveView(); if (activeView == null) return; string sss = activeView.ToString(); if (sss.StartsWith("