gpt4 book ai didi

ios - 使用 Segues 感受糟糕的设计布局

转载 作者:行者123 更新时间:2023-11-28 19:10:09 24 4
gpt4 key购买 nike

所以我正在开发我的第一个 iPhone 应用程序。我实际上相当深入。我已经从许多错误中吸取教训,但我觉得我犯了一个终极错误。我正在使用 segues 导航到不同的 View 。我深入了解了大约 5 个 segue View ,我意识到这会导致分配大量内存。换句话说, View A 调用 View B,B 继续进入 C,C 进入 D,等等。据我了解,当我到达 D 时,我现在打开了 A B C 和 D 的实例,这听起来不太好。我正在使用代表,例如如下所示:

这只是我在整个应用程序中所做的一个例子:

第一个 View :

@interface FirstViewController : UIViewController<SecondViewControllerDelegate>

@end

第二种观点:

@class SecondViewController;

@protocol SecondReviewOrderViewControllerDelegate <NSObject>

- (void)secondViewControllerDidCancel:(SecondViewController *)controller;

@end

@interface SecondViewController : UIViewController<ThirdViewControllerDelegate>
@property (strong, nonatomic) id <SecondViewControllerDelegate> delegate;
@end

第三个 View :

@class ThirdViewController;

@protocol ThirdReviewOrderViewControllerDelegate <NSObject>

- (void)thirdViewControllerDidCancel:(ThirdViewController *)controller;

@end

@interface ThirdViewController : UIViewController<>
@property (strong, nonatomic) id <ThirdViewControllerDelegate> delegate;
@end

等等,直到 View 4 和 5。

我的问题是,如果这是错误的(看起来确实如此),那么导航 View 和将数据从一个 View Controller 传递到另一个 View Controller 的正确方法是什么?感谢您提供任何提示。

最佳答案

From what I understand, by the time I get to D I now have instances of A B C and D open, which does not sound good

View Controller 本身是一个相当轻量级的对象,深入多个层次(例如,将五个 View Controller 推送到导航 Controller 堆栈)没有任何问题。但是,您可能持有的内存和图像不是轻量级的,因此请务必实现 didReceiveMemoryWarning 并在它到达时认真对待。

为响应 didReceiveMemoryWarning 放弃大量保留内存占用的策略是将其保存到磁盘(如果不能按需重新创建),然后使用惰性初始化来下次您被要求时再读一遍。

关于ios - 使用 Segues 感受糟糕的设计布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16410065/

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