views:

36

answers:

2

I have a view controller containing a status bar and a navigation controller on top and under these a UIScrollView that fill up the remaining space. The ScrollView displays an image. Is it possible to read the on-screen dimensions of the ScrollView without any hard-coded pixel values?

For the UIScrollView both frame and bounds return the size of the entire screen (320,480).

A: 

contentSize - (contentSize - contentOffset).

davidstites
Thank you. The problem is that contentSize returns the size of the image inside the ScrollView. I am trying to obtain (320,480-x) where x is height of status bar, navigation bar and a possible in-call status bar.
Ok, well your original question asked about finding the "on-screen dimensions of the ScrollView", not finding the height of those three components together. However, fortunately, those components are well known sizes. Why can't you just #define those sizes and use math to figure out what to display when you need to?
davidstites
@davidstites: If possible, I would like to avoid hard coded pixel values since these might change. It should be possible to read the size of the scrollview programatically. The scrollview is already rendered on-screen.
+2  A: 

I am using this code to determine scrollView scrolled to the bottom end... modify it as you need.

if (scrollView.contentOffset.y == (scrollView.contentSize.height) - (scrollView.frame.size.height)){
            //Reached at botton
}
KiranThorat
Thank you. Do you know if this code works even if the scrollView does not occupy the entire screen?
yes....it works despite of scrollView size..
KiranThorat