tags:

views:

447

answers:

3

Does anyone happen to know the maximum value for someView.bounds.size ? I'm creating a view hierarchy with where the accumulated bounding-box of all child views is equal to the root parent view.

Cheers, Doug

A: 

I don't know that there's a specific limit. I have created UIScrollViews that are hundreds of pages in width without any problem. Have you tried it and run into problems?

Paul

Paul Franceus
I am wondering about the maximum pixel dimensions for the contentView that a scrollView scrolls/zooms. What was the size in pixels of the pages you used?
dugla
I'm working on a book reader app. Some of the books are several hundred pages long, so that's 320 x 700 == 224000. What I'm saying is that I haven't seen a practical limit. I don't think it preallocates memory or anything.
Paul Franceus
A: 

I would not think there is a conceivable limit. Since the sizes are stored as floats, my guess would be that it is limited to CGFLOAT_MAX which is so large there is no need to worry about it.

Barry Hurley
Barry, my concern is instantiating a UIView - subclass there of - that blows past a fixed limit. Perhaps framebuffer size since hardware rendering is happening under the hood for everything on i(Phone|Pod).
dugla
+1  A: 

According to the UIView documentation:

Prior to iPhone OS 3.0, UIView instances may have a maximum height and width of 1024 x 1024. In iPhone OS 3.0 and later, views are no longer restricted to this maximum size but are still limited by the amount of memory they consume. Therefore, it is in your best interests to keep view sizes as small as possible. Regardless of which version of iPhone OS is running, you should consider using a CATiledLayer object if you need to create views larger than 1024 x 1024 in size.

In actuality, I was able to create UIViews and CALayers that were 2048 x 2048 in size on a standard iPhone / iPhone 3G in 2.x. Anything above that just stopped rendering.

Brad Larson
Thanks as always Brad. I'll look into CATiledLayer. One of the remaining bits of Cocoa I've been unclear is when I should implement at the CALayer level and when I should remain at the higher level UIView. Do you have any insight here? Thanks, Doug.
dugla
Performance-wise they are roughly the same. You can do some more advanced animations with CALayers, but you can just perform these on the CALayer backing of a UIView. The biggest reason I've found is Mac-iPhone cross-platform code, since CALayer's API is practically identical between the two platforms. For more, see the answers to this question: http://stackoverflow.com/questions/1447598/when-to-use-calayer-on-the-mac-iphone
Brad Larson