UIPageViewController with scrollview odd inset bounce - uiscrollview

Storyboard Screenshot
I wonder if anyone can shed any light on this for me.
I have a UIPageViewController as part of a SWRevealViewController structure as seen in the storyboard in the linked picture.
The UIPageViewController contains a series of UIViewControllers which have a vertical scroll views in them. The first page shows fine but when I swipe left to display a new page the view loads about 30 pixels to high and after 0.5 a second it drops down to the right place. After that when you scroll left and right it displays normally.
I have tried everything in this post so far and nothing has worked.
self.automaticallyAdjustsScrollViewInsets = false;
pageViewController.automaticallyAdjustsScrollViewInsets = false;
I am pretty sure it is something to do with UIPageViewController scroll inset but not sure what to do about it as I have tried everything I can think of in the last 3 days to try and fix this.
Thank you in advance

Not sure if this will help you, but I had a smaller 5px bounce issue scrolling images in a UIPageViewController. Nothing in the post you look through helped me either. But using a separate UIView as a container view between the individual page view controller's view and my UIImageView miraculously solved the issue for me.
So the hierarchy you want in your page's view controller's view is:
Main View
Container View
Your Actual view content

Related

How do I place text fields correctly within an animated UIView?

I am having problems with animating an UIView.
Everything is actually pretty basic:
My storyboard, because it easier to show a pic than to explain everything.
As you can see, there is a white UIView in the middle ( behind the gray label that says "Navi ein" ). It has to TextFields and one button in the right bottom corner.
I now added an animation to this UIView, so when the user clicks the button "Navi" (placed in the navi.-bar, top left), the UIView flys in from the top to the center (centerY-constraint and alpha animation, very simple).
The animation works for the UIView, but the TextFields and the button are not shown after it. My question is: why? I would really appreciate your help! :-)
Please let me know if you need some code extracts, but it shoudn't be necessary.
EDIT: I now found the text fields and the button in my View Debugger, I just forgot to uncheck "Only show displayed views". But how to figure out what makes them disappear (or not even appear) when the app launches?
View Debugger
I am so sorry! I just saw that I set all three items to hidden in my code.
I've never thought about that so far, I just looked in my storyboard.
So the problem is solved, I just deleted the lines "streetTextField.isHidden = true" and so on.
Nevertheless, I think it is good to hear and to see that some problems that seem to be hard are very easy to solve.

Swift resize view based on shown Items with autolayout

so im toying around with Autolayout with a Storyboard.
So i have a View, containing a Button and to its right a TextField. (Sadly i cant post Pictures here yet) ;)
now what im trying to do, is that by default, when my view gets shown the button is hidden, and the view kinda resizes it self to only contain the Text field.
And after the text field is clicked (selected) the button is shown and with this the view resizes itself to fit the button and the Textfield.
I think i might be able to do that in code, by simply updating the View width with the width of the contained and shown items.
But i feel like there has to be a easy way to do that with Autolayout.
So i tryed many things, but it just doesnt work, no matter what constrains i add.
How can i solve this ? Thanks in Advance.
EDIT
i forgot to mention, even if i remove the button from the superview i get bad results, i suppose the reason is that the constrains get messed up if i remove the Button.
So thats not an Option.

Why does ScrollView/Webview object in xcode include some kind of margin?

I'm really getting extremely mad with Xcode, trying to get a ScrollView correctly working. I'm having in fact 2 problems, but I'll separate it in two questions.
First of all, check out this screenshot.
Whether I drag the ScrollView to the top of view or just to the bottom border of the navigation bar, the web view (white square) stays about 60px from the nav bar, as you can see in the simulator.
The only way for me to have the web view aligned just below the nav bar is by dragging the Scrollview to the top of the view, at the top of the nav bar, and dragging the web view all the way to the top too.. Which places (in Storyboard) the web view behind the nav bar. Seems a bit odd, isn't it? The web view object has no attributes assigned to it which could have created that strange space.
What am I doing wrong?
Note: I have less than 40 hours of Xcode experience resulting in knowing nothing of Objective-C lines, but the Xcode interface itself. Learning by tutorials and practice
In the view controller add this method...
- (BOOL) automaticallyAdjustsScrollViewInsets
{
return NO;
}
This will fix it for you.

UIScrollView unintended content displacement in landscape mode

I' ran into an absolutely weird kind of problem I don't have a clue yet how to fix it, having been working on this without a break (except for eating, sleeping, drinking coffee and smoking) for almost two days now.
What I have:
I've got an UIScrollView inside my view controller, containing a certain number of textfields and a UICollectionView. With a button, I open another view controller for adding new data to the collection view. Back to my first view controller after the new data items have been added, I call invalidateIntrinsicContentsize on my UIScrollView and on my UICollectionView to resize them both to fit their content (I use Autolayout and let both of them hug their content). On both views I've implemented these methods to nicely fit their content, and this part works perfectly fine.
What my problem is:
If I add data to the UICollectionView in the way just described, and if I'm in landscape mode, the problems start: After getting back to my initial view controller and updating the intrinsic content sizes, the content of my UICollectionView is displaced - displaced in such a way, that the scrolling position of the content inside the UIScrollView before switching to the data-adding view now becomes something like a fixed content offset. If I scroll up now, I can reach at maximum that position of the content where it has been - by getting scrolled to - before I switched to the data-adding view controller.
Pictures (everyone loves that):
To illustrate that situation somehow difficult to explain, I appended two pictures. Red is the entire content area of the scroll view, dark green is the content, where both overlap the color is olive. The visible part of the UIScrollView is shown in the highlighted, bordered area.
Before updating the data, content is where it should be:
(source: grubbrother.com)
After updating the data and updating UI, content is displaced by former scroll position / contentOffset:
(source: grubbrother.com)
Please help me with this weird stuff. Unfortunately, I've got a tight deadline and need to move on with the project. Nevertheless I really don't know how to solve this or even what might cause it - I have absolutely no clue.
Despite I couldn't find out yet what causes the problem described in my question, I found a hack around it that at least somehow fixes the symptoms:
As I describe above, the unwanted content displacement that occurs when switching back to the UIViewController containg the buggy UIScrollView is equal to the contentOffset of the UIscrollView before switching to another scene.
Knowing this, I set the contentOffset to zero after my UIViewController disappears.
- (void)viewDidDisappear:(BOOL)animated
{
[super viewDidDisappear:animated];
[self.scrollView setContentOffset: CGPointZero];
}
When the view reappears, I scroll down to the newly added content at the bottom of the UIScrollView in question:
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
if (self.appearedFromActorsAdding)
{
[self.scrollView setContentOffset:CGPointMake(0, self.scrollView.contentSize.height - self.scrollView.frame.size.height) animated:YES];
}
}
Hope this helps anyone running into the same problem.

View Stretched in Storyboard iOS

can anyone tell me how to get my storyboard back to normal? I'm not sure what I did but all my views seem to be stretched and I can't see the navigation bars at the top of them where I need to make changes to buttons I've put up there.
full size screen Shot of Xcode
I do not know the cause, but I had this problem a while back.
In my situation I had a TabBarController pointing to several navigation controllers. To fix the problem I just deleted the TabBarController and replaced it with a new one.
If you have no TabBarController I would try just replacing the first NavigationController where the stretching takes place and it should fix all subsequent View Controllers.
The simplest solution is to roll back with your version control system.
That happened to me too. As Jeremy responses I had a tabBarController but I fixed by deleting the viewControllers associated to the tabBar, 1 of them was the one causing the problem, it was a Navigation controller wich I've changed the title, so the title was a little big and that did the controller to expand.

Resources