gpt4 book ai didi

iphone - 如何测试 shouldAutorotateToInterfaceOrientation?

转载 作者:行者123 更新时间:2023-11-28 20:18:26 25 4
gpt4 key购买 nike

我通过在 Controller 的 .h 文件中声明它使其可访问,
但我不喜欢仅出于测试目的而更改方法的可见性。

有没有其他方法可以使用 Objective-C 调用此方法,
前任。通过临时从测试类更改方法的可访问性?

最佳答案

好的,提醒一下:该方法在苹果类 UIViewController.h 中声明

// Override to allow rotation. Default returns YES only for UIInterfaceOrientationPortrait
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation;

所以它是一个公共(public)可访问的方法,你不需要在你的子类.h文件中再次声明它

所以,如果您想直接调用它进行测试,只需调用它(从任何引用您的类实例的类):

BOOL rotating = [yourController shouldAutorotateToInterfaceOrientation:1]; 

关于iphone - 如何测试 shouldAutorotateToInterfaceOrientation?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10188462/

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