gpt4 book ai didi

关闭时的 iOS presentViewController 动画

转载 作者:行者123 更新时间:2023-11-28 19:40:26 27 4
gpt4 key购买 nike

我这里有点问题。当我在我的主视图中单击我的跟踪按钮时,我会看到该按钮将我带到一个显示跟踪信息的新 View 。我遇到的一个问题是,当它移动到新 View 时,任何标签都开始变小,然后动画变成正常大小。我不确定我是否已经正确解释了它,但是当我将它设置为不动画时, View 正在动画。我将在下面附上代码。

谢谢。

- (IBAction)ordertrack {
UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIViewController *vc = [sb instantiateViewControllerWithIdentifier:@"track1"];
[self presentViewController:vc animated:NO completion:NULL];
}

更新:

我仍然没有找到任何有效的解决方案,我附上了下面的 gif 以显示您将看到后退按钮将调整大小的问题。

https://imgflip.com/gif/wwqq7

编辑:

为 Track1.m 添加代码

    //
// Track1.m
// uDropOff 3
//
// Created by Curtis Boylan on 06/01/2016.
// Copyright © 2016 Curtis Boylan. All rights reserved.
//

#import "Track1.h"

@interface Track1 ()

@end

@implementation Track1

- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/

- (IBAction)back {
UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIViewController *vc = [sb instantiateViewControllerWithIdentifier:@"main"];
[self presentViewController:vc animated:YES completion:NULL];

}
@end

最佳答案

@ChikabuZ 说的是实话。 (投票)

presentViewController:animated:completion: 上的animated 参数控制新的 View Controller 是滑到屏幕上还是只是出现。它不会影响新 View Controller 出现后所做的事情。

如果新的“track1” View Controller 在其设置代码中有动画,这些仍然会发生。你需要建立自己的机制来告诉它不要动画。 (也许将 dontAnimateInitialDisplay 属性添加到 track1 VC,并编写代码,以便如果 dontAnimateInitialDisplay 为真,则跳过动画。然后你d 像这样更改上面的代码:

- (IBAction)ordertrack {
UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
//Cast "vc" to the correct type so we have access to the
//dontAnimateInitialDisplay property
Track1VC *vc = (Track1VC *)
[sb instantiateViewControllerWithIdentifier:@"track1"];
vc.dontAnimateInitialDisplay = TRUE;
[self presentViewController:vc animated:NO completion:NULL];
}

关于关闭时的 iOS presentViewController 动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34631915/

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