2016-09-20 76 views
0

我的问题在于,当接到电话或WiFi热点处于活动状态时,底部的标签栏会移出屏幕。标签栏显示在屏幕外

No extended status bar Extended status bar

好像这就是我需要使用,但我不会用它 developer.xamarin.com/api/property/MonoTouch.UIKit.UIView.AutoresizingMask/

成功

如何解决此问题?

回答

1

这是一个布局问题。

我将以iPhone5S的屏幕尺寸为例来解释它。

对于正常情况,您的视图大小为“Frame = {X = 0,Y = 0,Width = 375,Height = 667}”,等于屏幕大小,但iOS系统会将所有视图的框架设置为“当个人热点被激活时,帧= {X = 0,Y = 20,宽度= 375,高度= 647}“。

它也会调用所有视图的方法“LayoutSubviews”,你可以捕捉它并处理它,如你所愿。

这是您的一个示例,您应该可以根据它自己找到解决方案。

using System; 
using CoreGraphics; 
using UIKit; 

namespace TestLayoutSubview 
{ 
    public partial class ViewController : UIViewController 
    { 
     private MyView myView; 

     protected ViewController(IntPtr handle) : base(handle) 
     { 
      // Note: this .ctor should not contain any initialization logic. 
     } 

     public override void LoadView() 
     { 
      myView = new MyView(); 
      this.View = myView; 
     } 

     public override void ViewDidLoad() 
     { 
      base.ViewDidLoad(); 
      // Perform any additional setup after loading the view, typically from a nib. 
     } 

     public override void DidReceiveMemoryWarning() 
     { 
      base.DidReceiveMemoryWarning(); 
      // Release any cached data, images, etc that aren't in use. 
     } 
    } 

    class MyView : UIView 
    { 
     private UIView bottomBar; 

     public MyView() 
     { 
      this.BackgroundColor = UIColor.Red; 

      bottomBar = new UIView(); 
      bottomBar.BackgroundColor = UIColor.Green; 
      this.AddSubview(bottomBar); 

      nfloat barHeight = 50; 
      bottomBar.Frame = new CGRect(0, UIScreen.MainScreen.Bounds.Height - barHeight, UIScreen.MainScreen.Bounds.Width,barHeight); 
     } 

     public override void LayoutSubviews() 
     { 
      base.LayoutSubviews(); 
      Console.WriteLine("Frame is changed."); 
      Console.WriteLine("Frame = "+Frame); 

      nfloat barHeight = 50; 
      bottomBar.Frame = new CGRect(0, UIScreen.MainScreen.Bounds.Height - barHeight - Frame.Y, UIScreen.MainScreen.Bounds.Width, barHeight); 
     } 
    } 
} 

希望它能帮助你。

如果你仍然需要一些建议,留言在这里,我会检查后者。

相关问题