6

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

dugla
  • 12,774
  • 26
  • 88
  • 136

3 Answers3

9

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
  • 170,088
  • 45
  • 397
  • 571
  • 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 Sep 29 '09 at 20:23
  • 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 Sep 29 '09 at 22:29
  • i had some issues trying to render a big WKWebView hierarchy to an UIImage using contexts, finally if using a print formatter it worked by setting the page size according to the size i wanted to render, only in the first page.. – Juan Boero Jan 12 '18 at 15:32
1

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
  • 410
  • 2
  • 7
  • 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 Sep 29 '09 at 18:49
  • 1
    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 Oct 01 '09 at 15:45
0

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
  • 567
  • 1
  • 5
  • 18
  • 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 Sep 29 '09 at 18:55