gpt4 book ai didi

ios - 将 View Controller 传递给彼此或确保仅初始化它们一次

转载 作者:行者123 更新时间:2023-11-29 03:17:42 25 4
gpt4 key购买 nike

我遇到的情况是这样的。

在 AppDelegate 中,我需要能够访问我在稍后的 View Controller 中创建的 SKView,以便我可以在进入后台时暂停 SKView。我知道能够做到这一点的唯一方法是在 AppDelegate 中创建 SKView,然后在我稍后用作属性的 View Controller 中设置它。缺点是,在首先创建该 View 之前,我无法设置该 View 。因此,我正在执行以下操作。

@property (nonatomic, strong) SKView *skView;
.
.
.
self.skView = [[SKView alloc] init];
SceneViewController *svc = [[SceneViewController alloc] initWithNibName:nil bundle:nil];
[svc setSkview:self.skView];

在 SceneViewController 中我有

@property (nonatomic, strong) IBOutlet SKView *skview;

我的问题是,我真的应该对 IBOutlet 属性设置强集吗?还有比这更好的方法来做我正在做的事情。

我还以相同的方式将 SceneViewController 传递给另一个 View Controller ,以便它也可以获得对它的引用,以允许它在适当的时间呈现 View 。我认为上述问题的答案也会对此有所帮助。

最佳答案

为什么不在拥有 SKView 的 View Controller 中监听 UIApplicationWillResignActiveNotification 并暂停?

关于ios - 将 View Controller 传递给彼此或确保仅初始化它们一次,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21480717/

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