0

iPad 用のインタラクティブな電子書籍アプリである最初のプロジェクトを構築しています

XCode の Single View App テンプレートから始めました

これまでのところ、プロジェクトは主に UIImageViews と MPMovieController ビデオの間の一連のブロック アニメーション トランジションであり、これまでのところ非常にシリアルです。

すべてが単一のビューの下の単一のビュー内でコーディングされます - 画像ビューはアルファアニメーションでフェードインおよびフェードアウトします

メモリの問題が発生し始めています。私はメモリ計測器を使用しましたが、実行時にインスタンス化されたいくつかのビデオを除いて、ほとんどすべてが最初にメモリにロードされていることがわかります (InterfaceBuilder からの画像)。

私の質問は、メモリをより有効に利用するためにコードを再編成するにはどうすればよいですか? 1 つのビュー コントローラーの下で異なるビューに分割する必要がありますか、それとも複数のビュー コントローラーを使用する必要がありますか?

そして、実装するのが最も簡単なのはどれですか?

4

4 に答える 4

0

I think you need to use multiple view controllers and separate your code in small separated views and objescts that controll you app flow..

于 2013-04-28T18:27:38.430 に答える
0

Images are very memory-intensive. So:

  • Do not load an image until you actually need it (for display). When you are done with it (the image view is no longer visible), release it (by setting that image view's image to nil). Do not maintain the images in an array or anything like that. Do not create the image views preloaded with images in advance in the nib.

  • When you actually need an image for display, load it in code using imageWithContentsOfFile:, not imageNamed:. Thus you prevent caching of the image.

  • It is a waste of memory to work with an image larger than the display size. If these images are large, you can save a lot of memory up front if you load the image at the actual size needed for display. This is easy to do with Image IO framework and CGImageSourceCreateThumbnailAtIndex.

于 2013-04-28T18:28:01.950 に答える
0

On the one hand it's better to have multiple views and so on..but it's a pain to rewrite code you worked on (unless it's absolutely necessary).

In my opinion if you don't have anything unnecessary in memory (i.e. when you take a view off screen you release the memory it used) you don't need to do anything.

After all, even if you split the code as it should have been, if your memory management is good, it will take the exact same memory.

于 2013-04-28T18:28:21.137 に答える