我的问题在于,当接到电话或WiFi热点处于活动状态时,底部的标签栏会移出屏幕。标签栏显示在屏幕外
好像这就是我需要使用,但我不会用它 developer.xamarin.com/api/property/MonoTouch.UIKit.UIView.AutoresizingMask/
成功如何解决此问题?
我的问题在于,当接到电话或WiFi热点处于活动状态时,底部的标签栏会移出屏幕。标签栏显示在屏幕外
好像这就是我需要使用,但我不会用它 developer.xamarin.com/api/property/MonoTouch.UIKit.UIView.AutoresizingMask/
成功如何解决此问题?
这是一个布局问题。
我将以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);
}
}
}
希望它能帮助你。
如果你仍然需要一些建议,留言在这里,我会检查后者。
这可以使用约束而不是自动调整大小掩码来完成。如果顶部酒吧的高度固定,底部视图的高度固定,而中间视图没有固定的高度,那么当状态栏展开时,您的中间视图将缩小而不是下拉任何东西。这里是约束教程
https://developer.xamarin.com/guides/ios/user_interface/designer/designer_auto_layout/