public override void ViewDidLayoutSubviews() { this.setupLayout(); //Console.WriteLine("ViewDidLayoutSubviews 1"); if (this.View.Bounds == CGRect.Empty) { return; } var orientationSavvyBounds = new CGRect(0, 0, this.View.Bounds.Width, this.heightForOrientation(this.InterfaceOrientation, withTopBanner: false)); //Console.WriteLine("ViewDidLayoutSubviews 2"); if (lastLayoutBounds != null && lastLayoutBounds == orientationSavvyBounds) { // do nothing; } else { //Console.WriteLine("ViewDidLayoutSubviews 2a"); var uppercase = this.shiftState.uppercase(); var characterUppercase = uppercase;// (NSUserDefaults.StandardUserDefaults.BoolForKey(kSmallLowercase) ? uppercase : true); //Console.WriteLine("ViewDidLayoutSubviews 2b"); this.forwardingView.Frame = orientationSavvyBounds; //Console.WriteLine("ViewDidLayoutSubviews 2c"); this.layout?.layoutKeys(this.currentMode, uppercase: uppercase, characterUppercase: characterUppercase, shiftState: this.shiftState); this.lastLayoutBounds = orientationSavvyBounds; //Console.WriteLine("ViewDidLayoutSubviews 2d"); this.setupKeys(); } if (bannerView != null) { this.bannerView.Frame = new CGRect(0, 0, this.View.Bounds.Width, Metrics.metric("topBanner")); this.toolbarView.Frame = new CGRect(0, 0, this.View.Bounds.Width, Metrics.metric("topBanner")); //this.bannerView.BackgroundColor = UIColor.Red; } if (spacerView != null) { this.spacerView.Frame = new CGRect(0, Metrics.metric("topBanner"), this.View.Bounds.Width, Metrics.metric("topSpacer")); //this.spacerView.BackgroundColor = UIColor.Yellow; } var newOrigin = new CGPoint(0, this.View.Bounds.Height - this.forwardingView.Bounds.Height); var fr = this.forwardingView.Frame; fr.Location = newOrigin; this.forwardingView.Frame = fr; }
CGFloat heightForOrientation(UIInterfaceOrientation orientation, bool withTopBanner) { var isPad = (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad); //TODO: hardcoded stuff; var actualScreenWidth = (UIScreen.MainScreen.NativeBounds.Size.Width / UIScreen.MainScreen.NativeScale); var canonicalPortraitHeight = (isPad ? (CGFloat)(264) : (CGFloat)(((orientation.IsPortrait() && actualScreenWidth >= 400) ? 226 : 216))); var canonicalLandscapeHeight = (isPad ? (CGFloat)(352) : (CGFloat)(162)); //var canonicalPortraitHeight = (isPad ? (CGFloat)(264) : (CGFloat)(((orientation.IsPortrait() && actualScreenWidth >= 400) ? 226 : 216))); //var canonicalLandscapeHeight = (isPad ? (CGFloat)(352) : (CGFloat)(162)); var topBannerHeight = (withTopBanner ? Metrics.metric("topBanner") : 0); var topSpacerrHeight = (withTopBanner ? Metrics.metric("topSpacer") : 0); return((CGFloat)(orientation.IsPortrait() ? canonicalPortraitHeight + topBannerHeight + topSpacerrHeight : canonicalLandscapeHeight + topBannerHeight + topSpacerrHeight)); }
public override void ViewDidLoad() { base.ViewDidLoad(); this.setupKludge(); var aBanner = this.createBanner(); if (aBanner != null) { toolbarView = new UIToolbar(new CGRect(0.0f, 0.0f, this.View.Frame.Size.Width, Metrics.metric("topBanner"))); cleanToolbar(); aBanner.Add(toolbarView); aBanner.Hidden = true; this.View.InsertSubviewBelow(aBanner, siblingSubview: this.forwardingView); this.bannerView = aBanner; } var aSpacer = this.createSpacer(); if (aSpacer != null) { aSpacer.Hidden = true; this.View.InsertSubviewBelow(aSpacer, siblingSubview: this.forwardingView); this.spacerView = aSpacer; } }