Extending a vertical UIScrollView with pagingEnabled under the navigation and status bars - iphone

I'm trying to extend a vertical UIScrollView with pagingEnabled underneath the navigation and status bars.
For other, non-paging scroll views, increasing the frame upwards and adjusting contentInset works fine. However, doing this with a paging scroll view affects the amount paged each swipe – effectively breaking paging as the pages don't line up to the height paged.
Trying to use this sort of solution, i.e. maintaining the frame the same size and setting clipsToBounds = NO, kindof works. However, it only displays the above cell if it's actually visible within the frame – the 66 pixels underneath the status and navigation bars don't count.
How can I do this?

On your view controller you will need to set
self.automaticallyAdjustsScrollViewInsets = NO;
This should effectively stop adding the extra spacing above the view.

Related

Make Area Page-able

How Can I make the green area of the screen shot of my app be able to scroll with the paging animation and page indicators?I would like for me to add more icon-buttons to it with keeping the header the same size.
First you need a scroll view and your view has to be inside of the scroll view.
Then you need to enable paging on the scroll view
[scrollView setPagingEnabled:YES];
If the value of this property is YES, the scroll view stops on multiples of the scroll view’s bounds when the user scrolls. The default value is NO.
If you want to have page indicators you need to use UIPageControlwhich you will have to manage yourself as far as I know. You could always check after scrolling (see UIScrollViewDelegate ) which page you are on based on the contentOffset property of the scroll view.

UIScrollView in iOS doesn't response scroll to top

I have two UIScrollViews, one is horizental, the other is like page on the horizontal view. I want to click the status bar and have the vertical scrollView scroll to the top, but it doesn't work.
I searched for some information that said I must set UIScrollView.scrollsToTop=NO, but it doesn't work. Could somebody tell me why?
The scroll view only scrolls to the top if there is a single scroll view present with the scrollsToTop property set to YES.
Make sure it's set to NO on your horizontal scroll view and all the child, vertical scroll views contained within. Then, using the horizontal scroll view's delegate, as one vertical scroll view leaves the visible area, toggle the property to NO and toggle the incoming vertical scroll view's property to YES.

iPhone how to implement a "Wide" UITableViewCell?

I'd like to have a UITableView with cells wider than 320 points. The user should be able to scroll sideways to be able to view different parts of a UITableViewCell. Is this kind of behavior possible with a UITableView, or should I go and try to implement a tiling UIScrollView?
I tried wrapping a UITableView within a UIScrollView, and the results are terrible - they compete for the scroll gestures and most of the time the scroll view wins, preventing the table from being traversed vertically.
Any input is appreciated!
Thank you!
Update: I tried the proposed solution and it scrolls properly, but the tableview is still only 320 pixels wide. Is tableView's width linked to the window bounds ?
Wrapping the table view with the scroll view is the right way.
UIScrollView with
Show horizontal scrollers
scrolling enabled
autosize to full screen
Inside that, a UITableView
shows vertical scrollers
scrolling enabled
Then I set the table view's frame, with w, being the calculated width of the table view with all columns, whatever your width, and kTableScrollViewHeight being the fixed height of both the table view and the scroll view, in my case, for example 367 points (screen minus status, navbar and tabbar):
tv.frame = CGRectMake(0, 0, w, kTableScrollViewHeight);
and the scroll view's content size
scrollView.contentSize = CGSizeMake(w, kTableScrollViewHeight);
If you want the scroll-to-top behavior when the user taps the status bar, you might want to set
scrollView.scrollsToTop = NO;
because otherwise the scroll view will take away the tap from the table view.

UIScrollView Updating contentSize Causes Scroll

I have a UIScrollView that has a single child view within it. If I set the contentSize of the UIScrollView immediately after creation, everything works as I expect and I get scrolling.
The challenge is the view within the UIScrollView is dynamically sized. The width is fixed, but the height is unknown at the time I set up the scrollview.
When I do a [scrollView setContentSize:CGRectMake(...)] after the inner view does it's thing, the scrollview updates to the proper size and scrolling works. So basic scrolling works fine.
However, the major problem is that when I setContentSize at a later point, the UIScrollView decides to scroll down(with animation) towards the end of the scrollview, which is not what I want, I want the scroll to stay at the top, and let the contents within the scrollview either get bigger or smaller, without changing the apparent scroll position.
What am I missing?
Why don't you also call [scrollview setContentOffset:CGPointMake(0,0)]; when you call the setContentSize?
To force UIScrollView to scroll only e.g. horizontally, I always set non-scrollable value for contentSize to 0, using:
CGSizeMake(contentSize.width, 0).

Mimic behaviour of UITableView section headers staying visible during scroll

When you have a sectioned, plain-style tableview on the iPhone, such as in the Contacts app, the section headers remain visible when you scroll past them until they are pushed offscreen by the next section header.
Does anyone know how to achieve something like this in an ordinary scrollview? I already have one scrollview nested in another to get horizontal paging with vertical smooth-scrolling, so I'm reluctant to add a third scrollview.
Cheers
Basically I did a bunch of maths in scrollViewDidScroll: and set the frame of the subview.
Edit:
Well my exact requirements were a bit different than the question I asked, I have a footer view as opposed to a header view. Basically in scrollViewDidScroll I have:
CGRect frame = self.footerView.frame;
frame.origin.y = MIN(self.bounds.size.height -
self.footerView.frame.size.height +
self.contentOffset.y,
self.contentSize.height);
self.footerView.frame = frame;
This ensures the footer view, which is a subview of the scroll view, is always visible at the bottom of the scroll view, and there is never a gap between the footer view and the bottom of the content view.