viewcontroller 不遵守约束 (xamarin.ios)
the viewcontroller does not respect the constraints (xamarin.ios)
我在 xamarin.ios 上尝试幻灯片 t运行saction,其中 vc2(代码中初始化的那个)流过 vc1(前一个)并且是全屏的,但是在我的代码中,vc1 与动画结束时不受尊重的约束相互渗透,导致这种方式 ..
而结果应该是这样的..
现在我已经尝试解决它一段时间了,我 运行 没有解决方案,我仍然不明白为什么它看起来像这样,代码是这样的..
public void SlideTo(UIView View, string A)
{
var CC = CGAffineTransform.MakeTranslation(View.Bounds.Size.Width, 0);
var DD = CGAffineTransform.MakeTranslation(0, 0);
//Istanzio il vc
var storyboard = UIStoryboard.FromName("Main", null);
var vc = storyboard.InstantiateViewController(A);
CALayer gradient = new CALayer();
gradient.Frame = vc.View.Bounds;
vc.View.Layer.InsertSublayer(gradient, 1);
View.AddSubview(vc.View);
//Centro quella giusta
vc.View.Transform = true ? CC : DD;
UIView.Animate(1, 0, UIViewAnimationOptions.CurveLinear, () =>
{
vc.View.Transform = true ? DD : CC;
}, null);
}
请仅解决 xamarin.ios(不是 swift)
安全区域是一种思考应用程序可见性 space 以及如何在视图和超级视图之间添加约束的新方法。
这个问题可能是SafeArea
造成的。
这里你可以修改代码试试看:
public override void ViewDidAppear(bool animated)
{
base.ViewDidAppear(animated);
//suberView is your table view
View.Add(suberView);
suberView.TranslatesAutoresizingMaskIntoConstraints = false;
var safeGuide = View.SafeAreaLayoutGuide;
suberView.LeadingAnchor.ConstraintEqualTo(safeGuide.LeadingAnchor).Active = true;
suberView.TrailingAnchor.ConstraintEqualTo(safeGuide.TrailingAnchor).Active = true;
suberView.TopAnchor.ConstraintEqualTo(safeGuide.TopAnchor).Active = true;
suberView.BottomAnchor.ConstraintEqualTo(safeGuide.BottomAnchor).Active = true;
View.LayoutIfNeeded();
}
我在 xamarin.ios 上尝试幻灯片 t运行saction,其中 vc2(代码中初始化的那个)流过 vc1(前一个)并且是全屏的,但是在我的代码中,vc1 与动画结束时不受尊重的约束相互渗透,导致这种方式 ..
而结果应该是这样的..
现在我已经尝试解决它一段时间了,我 运行 没有解决方案,我仍然不明白为什么它看起来像这样,代码是这样的..
public void SlideTo(UIView View, string A)
{
var CC = CGAffineTransform.MakeTranslation(View.Bounds.Size.Width, 0);
var DD = CGAffineTransform.MakeTranslation(0, 0);
//Istanzio il vc
var storyboard = UIStoryboard.FromName("Main", null);
var vc = storyboard.InstantiateViewController(A);
CALayer gradient = new CALayer();
gradient.Frame = vc.View.Bounds;
vc.View.Layer.InsertSublayer(gradient, 1);
View.AddSubview(vc.View);
//Centro quella giusta
vc.View.Transform = true ? CC : DD;
UIView.Animate(1, 0, UIViewAnimationOptions.CurveLinear, () =>
{
vc.View.Transform = true ? DD : CC;
}, null);
}
请仅解决 xamarin.ios(不是 swift)
安全区域是一种思考应用程序可见性 space 以及如何在视图和超级视图之间添加约束的新方法。
这个问题可能是SafeArea
造成的。
这里你可以修改代码试试看:
public override void ViewDidAppear(bool animated)
{
base.ViewDidAppear(animated);
//suberView is your table view
View.Add(suberView);
suberView.TranslatesAutoresizingMaskIntoConstraints = false;
var safeGuide = View.SafeAreaLayoutGuide;
suberView.LeadingAnchor.ConstraintEqualTo(safeGuide.LeadingAnchor).Active = true;
suberView.TrailingAnchor.ConstraintEqualTo(safeGuide.TrailingAnchor).Active = true;
suberView.TopAnchor.ConstraintEqualTo(safeGuide.TopAnchor).Active = true;
suberView.BottomAnchor.ConstraintEqualTo(safeGuide.BottomAnchor).Active = true;
View.LayoutIfNeeded();
}