gpt4 book ai didi

ios - 将 rootViewController 动画更改为 SplitViewController?

转载 作者:塔克拉玛干 更新时间:2023-11-02 07:47:19 27 4
gpt4 key购买 nike

我有一个以 tableView 开始的项目,但是当用户点击“设置”按钮时,我想将更改动画化为 splitViewController。

我可以轻松地更改 rootViewController,但是动画并不像宣传的那样:

UIViewController *controller = [self.storyboard instantiateViewControllerWithIdentifier:@"SetupViewController"];
AppDelegate *app = (AppDelegate *)[[UIApplication sharedApplication] delegate];

[UIView transitionWithView:self.navigationController.view
duration:0.75
options:UIViewAnimationOptionTransitionCrossDissolve
animations:^{
app.window.rootViewController = controller;

}
completion:nil];

有什么方法可以让 rootViewController 的变化动起来吗?

最佳答案

这有点 hackie,但尝试在动画之前设置 root 并再次返回,这样新的 ViewController 在您开始动画时获得正确的大小:

UIViewController *controller = [self.storyboard instantiateViewControllerWithIdentifier:@"SetupViewController"];
AppDelegate *app = (AppDelegate *)[[UIApplication sharedApplication] delegate];

UIViewController *currentController = app.window.rootViewController;
app.window.rootViewController = controller;
app.window.rootViewController = currentController;

[UIView transitionWithView:self.navigationController.view.window
duration:0.75
options:UIViewAnimationOptionTransitionCrossDissolve
animations:^{
app.window.rootViewController = controller;

}
completion:nil];

这个解决方案对我有用。

关于ios - 将 rootViewController 动画更改为 SplitViewController?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19863199/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com