I have an iPhone app that starts out in portrait mode. When the app is rotated to landscape a new view is pushed on using:
[self presentModalViewController:viewController animated:YES];
This landscape view contains a UIScrollView that scrolls vertically in the landscape position. The scroll view frame height is equal to the landscape height (320 points) and the content size height of the scroll view is 3 times the landscape height (so 960 points). I have vertical paging enabled, so there are 3 pages.
When the view appears, the scroll view is scrolled to the top as I expect. But in iOS 5, the scroll view then randomly jumps to some position where it is scrolled up. I've commented out my viewDidAppear method and it still does this. In iOS 6 it works fine and this doesn't happen.
Does anyone have any idea what is going on here?
So add a [scrollView setContentOffset:CGPointZero] in the viewWillAppear (or somewhere else).
Could help, but not the best way to deal with it ;-)
Related
I have a UIViewController containing a scrollView.
The scrollView is pinned (0,0,0,0) to the Safe Area, this way:
In the body of the viewController viewDidLayoutSubviews, I add some views to the Content View of this scrollView.
I see no issue in iPhone 6 simulator, but in iPhone X simulator something strange happens: the last view I add to the scrollview goes partially behind the home indicator:
I erroneously thought this was the kind of issue solved by the Safe Area.
What could I do to solve this issue?
As of iOS 11 and new iPhone X devices and forward this is the default behavior of safeAreaLayoutGuide.
Scroll view subclasses like table view and collection view handles this problem automatically if you pin the bottom anchor to safe area.
Since you are populating a scroll view manually you need to get the bottom safe area height and inset the scroll view with that value.
You can do it like this:
scrollView.contentInset.bottom = view.safeAreaInsets.bottom
Change the ScrollView BottomConstraint related to superviewBottom instead of safeArea.
I have components in a UIScrollView. My scroll view works when it was in iOS 10 and Xcode 8 but after the update, my scroll view does not scroll. However, the scroll bar does scroll and can keep scrolling until it gets smaller and smaller. It is just the elements in the scroll view itself that doesn't scroll.
I have tried doing content size bigger than the frame size but it does not fix it. Here is my current views hierarchy.
If anyone can help me debug this, it would be greatly appreciated.
I fixed this by adding a content view to the scroll view, and then the scroll view should be the subview of main view. The hierarchy should look like this.
I encountered pretty much the same problem (scroll indicator moves and gets smaller but content doesn't move). In my case it was resolved by changing the AutoLayout constraint for the top of my content view within the UIScrollView. I had pinned it to the Frame Layout Guide rather than the top of the superview.
I have an app which shows two images housed within a UIScrollview.
The scrollview is of size (320, 530), underneath it is an imageview size (320,38), this acts like a dock at the bottom of this screen, ( in fact it has to be there at the bottom of all screens in this app).
As it stand the scrollview works fine and the images switch from one to anothr when the user
moves the scrollview.
The problem is, I need the scrollview height to go all the way down ( from 530 to 568), and end up behind the dock imageview, when I change its height and the height of images within it, it just stops scrolling.
Is this impossible in scrollviews? does it have to have all of its screen real estate as top view?
Any solutions for this?
Thanks.
Update :
so I worked on the alpha and the image constraints, and the bottom imnage is located properly,
still the scrolling is not functioning.this is the latest code with changes.
http://ge.tt/4LYJGWl/v/0?c
thanks.
This is certainly possible. Add a full height scroll view to the controller's view, then add the small image view to the bottom. In the scene list at the left move that image view up so it's directly underneath the main view, which will make it a subview of that view rather than the scroll view (you'll then need to move the scroll view up above the image view so the image view will appear on top). You'll probably have to change some constraints to pin it to the bottom, and give it an alpha value less than 1 so the scroll view will show through.
After Edit
This is the screen shot of the scene from your updated code:
You only have one view that's directly under the main view, your scroll view. Compare that to my image.
I'm developing an app, where I have one horizontally scrollable UIScrollView fullscreen with pagination that contains multiple (let's say 3) vertically scrollable UIScrollViews, each also fullscreen. They're positioned without margins, the left ones origin is (0,0).
Each vertically scrollable UIScrollView consists of buttons placed one above the other, each when clicked, presents a ViewController:
[self presentViewController:someViewController animated:YES completion:nil];
Now this code works fine for the two right UIScrollViews, but it's buggy for the left one:
The buttons bellow the height of the horizontal UIScrollView are not clickable. So if the height of the horizontal UIScrollView is 440px, any UIButton with origin.y > 440 is uncklickable.
If the UIScrollView is slightly scrolled down and a button is clicked (that is not below 440px), the whole UIScrollView gets "moved" down and gets sorta laggy while the requested view controller gets presented. When this view controller gets dismissed, the scroll view stays lower. If I scroll it back up and press a button, it magically jumps up to where it should be.
Now for the fun part!
If I change the origin of the left UIScrollView to (1,0), this issue dissapears! What could be making this problem?
Some added code:
[horizontalSV setDelegate:self];
[horizontalSV setContentSize:horizontalContentView.frame.size];
[horizontalSV addSubview:horizontalContentView]; // View containing vertical scroll views, it's set up in IB
[horizontalContentView setFrame:CGRectMake(-1, 0, 961, 440)]; // This is now used for the hack
// Now imagine three of these
firstSVcontent = [[VerticalContentView alloc] init]; // Setting the content view
[firstSVcontent setTitle:title];
[firstSVcontent setButtons:blahblah];
[firstVerticalSV setContentSize:firstSVcontent.view.frame.size]; // Setting vertical scroll view
[firstVerticalSV addSubview:firstSVcontent.view];
I've resolved this issue almost a year later!
The problem was, I was doing most of my view managment in a XIB file and then I just read those content views and scroll views in my viewDidLoad method and put them together.
Now I've rewritten my code to create all scroll views and content views programatically and everything works without a problem.
I have UIViewController with a UIView with UITableView inside.
All works fine in Landscape mode but when the device is rotated to Portrait, bottom half of UITableView is not accessible (can't even select any row in the bottom half or make table scroll). All rows are displayed correctly.
I am re-framing and repositioning UIView and UITableView on rotation.
Any ideas how to solve this problem?
You should adjust the autosizing in Interface Builder or in code.
I think the UITableView's height is still same with the value in Landscape mode after you rotate device to Portrait.
You can identify it by NSlog your UITableView's CGRect
NSlog(#"frame:%#",[NSStringFromCGRect(UITableView's CGRect)]);