IOS如何检测方向完成
IOS how to detect the orientation completed
我有一个基于 UIView 的渲染器。旋转设备多次调用 layoutSubviews 时,我可以看到动画发生变化。旋转设备完成后,有没有办法检测视图的动画。
这是布局子视图调用
public override void LayoutSubviews()
{
base.LayoutSubviews();
var size = base.Frame;
Element.OnSizeChanged((int) size.Width, (int) size.Height);
}
看看viewWillTransitionToSize
。
UIKit calls this method before changing the size of a presented view controller’s view. You can override this method in your own objects and use it to perform additional tasks related to the size change. For example, a container view controller might use this method to override the traits of its embedded child view controllers. Use the provided coordinator object to animate any changes you make.
refer apple documentation了解更多详情!!
您可以通过 ViewWillTransitionToSize
方法中的协调器完成处理程序捕获 UIViewController
旋转的结束:
public override void ViewWillTransitionToSize(CGSize toSize, IUIViewControllerTransitionCoordinator coordinator)
{
coordinator.AnimateAlongsideTransition(
(IUIViewControllerTransitionCoordinatorContext obj) => { },
(IUIViewControllerTransitionCoordinatorContext obj) =>
{
Console.WriteLine("Transition Completion");
});
base.ViewWillTransitionToSize(toSize, coordinator);
}
我有一个基于 UIView 的渲染器。旋转设备多次调用 layoutSubviews 时,我可以看到动画发生变化。旋转设备完成后,有没有办法检测视图的动画。
这是布局子视图调用
public override void LayoutSubviews()
{
base.LayoutSubviews();
var size = base.Frame;
Element.OnSizeChanged((int) size.Width, (int) size.Height);
}
看看viewWillTransitionToSize
。
UIKit calls this method before changing the size of a presented view controller’s view. You can override this method in your own objects and use it to perform additional tasks related to the size change. For example, a container view controller might use this method to override the traits of its embedded child view controllers. Use the provided coordinator object to animate any changes you make.
refer apple documentation了解更多详情!!
您可以通过 ViewWillTransitionToSize
方法中的协调器完成处理程序捕获 UIViewController
旋转的结束:
public override void ViewWillTransitionToSize(CGSize toSize, IUIViewControllerTransitionCoordinator coordinator)
{
coordinator.AnimateAlongsideTransition(
(IUIViewControllerTransitionCoordinatorContext obj) => { },
(IUIViewControllerTransitionCoordinatorContext obj) =>
{
Console.WriteLine("Transition Completion");
});
base.ViewWillTransitionToSize(toSize, coordinator);
}