UIScrollView includes extra space at bottom - ios

I have a UIScrollView which continually adds extra space at the bottom of its scroll area on iOS 7. If I rotate the device, the problem fixes itself, however, before rotating after first navigating to the view controller, the extra space always appears. I've included an image below:
What I've tried:
Set automaticallyAdjustScrollViewInsets to NO
Checked contentSize, contentOffset and contentInset. All appear fine.
I'm not sure what else to try to solve this issue, and would greatly appreciate any help or direction here!
Edit: As another layer of complexity to this issue... I call a method, updateScrollViewContentSize in my viewDidAppear: method. When I rotate, and it somehow fixes itself, this same method is called. So my contentSize is being set when my view appears and when I rotate.
To make things worse, the content size is always set to 638... Whether there is extra space or not. But, for some reason, the scrollView ignores this until we rotate.
Here is the method to update the contentSize:
- (void)updateScrollViewContentSize {
[self.scrollView setContentSize:CGSizeMake(self.scrollView.frame.size.width, (self.feedbackFooterView.frame.origin.y + self.feedbackFooterView.frame.size.height + 20))];
}

Related

Horizontal UIScrollview always bouncing back, even after setting contenSize bigger - iOS

I have implemented a horizontal UIScrollview (adding buttons into it) but it always bounces back to original position after I scroll it. Searched a lot but the answers were of no luck as yet.
This is the scroll view below, of the same width as screen,
And this is the view inside it, which is of 800+ width,
Also in me class, I have implemented the following code:
_imageEffectsScrollView.contentSize = CGSizeMake(832, 80);
In fact it just now scrolls a little bit, instead of bouncing back ( like before ):
Please help, how can I make it scroll properly. Thanks!

UIScrollView Always Bounces back to Top

I've seen a couple of other posts on this, and have attempted to implement their suggestions, but I'm still having the same problem. I have a UIScrollView the contains a UIContentView that in turn contains various labels and a UIWebView. The content scrolls well enough, but it's too long for the screen (by design - that's why I am using a scroll view). As my finger slides to the top of the screen, I need to let go and move my finger to the bottom to continue scrolling. The instant that I let go of the screen, the content bounces right back to the top, thereby negating the scrolling that I have done. This makes it impossible to see the remaining information farther down.
I know that my UIContentView has a height that is greater than the maximum y-value of the last object. I verified this with some NSLog statements to print out what the last y value is. What else might I be missing? I've made many other UIScrollViews work, so I don't know what I am overlooking here.
Thanks!
- (void) viewDidLayoutSubviews
{
[super viewDidLayoutSubviews];
[self.scrollView layoutIfNeeded];
self.scrollView.contentSize = self.contentView.bounds.size;
}
You shouldn't be doing that in viewDidLayoutSubviews. Assuming that contentView has a fixed size, and isn't being autoresized or changed by auto-layout, then you can put the line
self.scrollView.contentSize = self.contentView.bounds.size;
in the viewDidLoad method.
The layoutIfNeeded line serves no purpose and should be removed.

Unresponsive area in UITableView in landscape orientation

I'm developing an iPad application where I have a screen with UITableView hosted on UIScrollView. UITableView's leading space and trailing space is being pinned to superview.
I'm using Autolayout in my project.
When this screen appearing in landscape mode or rotated to it all visible elements of UITableView being resized correctly. However area after x=768pt is being untouchable. It's definitely area because beginning of editable elements (text view and text field) are being touchable.
I checked contentSize of table, it's being OK (1024 in my case).
Also when I rotate iPad from landscape to portrait contentSize of table still stays landscape (1024). I tried solution from this topic: bug in UITableView layout after orientation change and it worked. Don't know if this is connected to my issue.
I tried to place regular view instead of my UITableView. On this view after rotation touch area was OK. However when I placed my table on this view right area still was unresponsive.
Table's property clipsToBounds set to YES so it seems that content is not becaming outside of UITableView.
Please point to what may cause this issue. Right now I'm completely out of ideas what may cause this.
I found a solution. The problem was in overriden method -(void)layoutSubviews in my custom cell. I simply forgot to call [super layoutSubviews] in it.
Never forget to call [super layoutSubviews] in any non-standard view.
Hope my solution will help someone not to waste hours on simple issue.

UIScrollView unwanted scrolling after addSubview or changing frame

I have a UIScrollView filled with subviews, all is well when creating it and initially filling it.
But when I add a new subview that is positionned outside of the visible screen portion, or when I just resize an existing subview that is also outside of the visible screen portion, there is a subsequent 0.3s-long scroll animation (I can see it happening from my delegate) that seems to match the newly added/resized element.
Attempts:
pagingEnabled is always NO.
Setting scrollEnabled to NO during subview manipulations doesn't help.
Doing a setContentOffset:animated:NO after subview manipulations doesn't prevent the animation.
One single giant subview with all my subviews in it doesn't help.
My current workaround is to initially set the frame to fit inside the visible screen portion, or doing resizing work inside another superview, but it feels dirty, and won't handle all situations...
Is there a way to prevent this automatic scrolling animation when programmatically manipulating subviews?
Xcode 4.3, iOS SDK for 5.1.
I too discovered this problem and found this solution http://www.iphonedevsdk.com/forum/iphone-sdk-development/94288-disabling-uiscrollview-autoscroll.html
It involves subclassing the UIScrollView and entering no code in the following method.
- (void)scrollRectToVisible:(CGRect)rect animated:(BOOL)animated {
}
Like the guy says on the link I've found it works and no problems so far. Hope it works for you.
I had this problem because I set the content size of the scroll view prior to adding the subview.
As soon as I change the code so that the content size of the scroll view was set after adding the subview the problem went away.

UIScrollView not working

I have a UIScrollView with a View inside of it. Inside of that view is a bunch of buttons, labels, etc that fit in the View when in Portrait mode...When the iPad is rotated, I want the scrollView to kick in so the user can scroll to the bottom of the view. The app runs, but when I rotate it, the scroller never works...I believe I've wired everything up correctly and I have this code in the viewDidLoad event:
[scrollview addSubview: masterView];
scrollView.contentSize = [masterView sizeThatFits:CGSizeZero];
Is there something else I am missing? Do I need to modify the size when the iPad rotates?
thanks
There may be a problem with the content size of the UIScrollView. Without the contentSize being set larger than the actual scrollView size, scroll bars won't be shown.
You can code this in with something like this:
[scrollView setContentSize:CGSizeMake(2000,2000)];
And then changing the content size to the actual content size of what you are putting in the UIScrollView (scrollView).
If you look at the results of [masterView sizeThatFits:CGSizeZero] (e.g. NSLog or set a breakpoint in your debugger, I think you will find that it's not what you expected it to be. You might find that masterView has autoResize parameters set (which is common for a view that covers the entire screen), which means that it might, itself, be getting resized too short to fit all of its controls and scrollView is simply grabbing this shortened value itself. Take a look at that CGSize and the problem will be obvious.
I faced similar situation but my case was iPhone.
Remember that content should be larger than scroll for scrollView to kick in.
"Why would you want to go down if everything is visible in front of you ?"
use the following code:
[scrollView setContentSize:CGSizeMake(intValue, intValue)];
intValue: Integer values setting width and height of scroll.
Even if it doesn't works, don't worry there are loads of other options to figure out the solution:
1. NSLog
2. Breakpoints
3. Put up errors you are getting from console on stackoverflow

Resources