iphone - iOS 漫画阅读器 - 这是一个可行的设计吗?

标签 iphone ios xcode

由于截止日期即将到来,我正在寻找最简单可行的方法来组合漫画阅读器应用程序。

我目前的设计如下:

  • 每个页面都是 UIViewController 的子类,在 UIScrollView 中包含一个 UIImageView
  • 点击屏幕右侧会将另一个页面推送到 UINavigationController 上。

通过这个基本方案,我将把 20 多个 UIViewController 相互叠加,每个页面一个。

我的问题是:这是对 UIViewController 的滥用,还是一个不明智的解决方案?

我想宁愿做的是拥有一个UIViewController来移动一些包含页面内容的 subview 。但如果上述想法可行,那就更容易了——我不必手动编写任何页面转换逻辑和动画,只需推送即可。

我是 iOS 新手,正在努力学习足够的知识,以便在有限的时间内找到最佳解决方案,因此非常感谢任何帮助或指导。以这种方式设置应用程序显然是不被禁止的,但是在了解实例化 ViewController,然后在另一个 UIViewController 中使用它的 .view (我在应用程序的另一部分中这样做)之后,确实是很糟糕的做法,我怀疑我对如何使用 UIViewController 的理解。

最佳答案

我不知道你会认为这是一种滥用,也许是凭内存说话?或者也许这不是解决这个问题的最优雅的方法?

这当然不是解决这个问题的最佳方法,我确信操作系统处理这个问题不会有问题(对于旧版本的硬件,我可以想象一些故障)。例如,尝试在 Twitter iOS 应用程序中进行一些辱骂行为,转到您的个人资料,然后查看您的一条推文,然后转到该推文的个人资料或类似的内容,一次又一次。或者浏览不同的配置文件和推文,我发现内存管理非常好。因此,只要实现 didReceiveMemoryWarning 方法,就不必担心内存问题。

来自 UIViewController 类 reference page :

Memory Management

Memory is a critical resource in iOS, and view controllers provide built-in support for reducing their memory footprint at critical times. The UIViewController class provides some automatic handling of low-memory conditions through its didReceiveMemoryWarning method, which releases unneeded memory. Prior to iOS 3.0, this method was the only way to release additional memory associated with your custom view controller class but in iOS 3.0 and later, the viewDidUnload method may be a more appropriate place for most needs.

When a low-memory warning occurs, the UIViewController class purges its views if it knows it can reload or recreate them again later. If this happens, it also calls the viewDidUnload method to give your code a chance to relinquish ownership of any objects that are associated with your view hierarchy, including objects loaded with the nib file, objects created in your viewDidLoad method, and objects created lazily at runtime and added to the view hierarchy. Typically, if your view controller contains outlets (properties or raw variables that contain the IBOutlet keyword), you should use the viewDidUnload method to relinquish ownership of those outlets or any other view-related data that you no longer need.

现在,如果我有时间实现另一个解决方案,我可能会设计一个模型,其中包含每个 View 中的所有内容。

型号

  • 标题 (NSString)。
  • 页面路径 (NSArray)。
  • 当前索引 (int)。
  • TransitionType (ComicBookTransitionType)。

查看

  • MainView (UIViewController)。
  • MyModel (ComicBookModel)。
  • NextPage (UIView)。 (我可能会预先加载此属性,以保证从一个页面到另一个页面的平滑过渡,就像下一个属性一样)。
  • 上一页 (UIView)。

类似的事情,剩下要做的(也是真正棘手的部分)就是将值从 MainView 更改为 NextPage 或上一页。

另一种选择是选择 Ebook Framework .

关于iphone - iOS 漫画阅读器 - 这是一个可行的设计吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9252157/

相关文章:

iphone - 异步函数执行?

xcode - 将 FMDB SQLite 结果附加到 Swift 数组

swift - 本地化 FirebaseUI 身份验证

ios - UIButton 和 UITextField 不响应作为 UIViewController 的一部分

iphone - 适用于 iOS 的 facebook sdk 是否使用加密?

objective-c - Objective-C - 设置 UIPickerView 委托(delegate)

iphone - 查看过渡动画

ios - 如何更新祖 parent TableView

ios - Alamofire 不会使用 Cocoapods 在空的 Swift 项目中构建

iphone - 检查 MBProgressHUD 状态是否隐藏/显示