Before starting to sprout code, I want to know if I have a conceptual mistake, since I am new to Swift and Xcode.
I have a scrollview that resizes properly and covers the entire screen´s witch when the screen orientation changes. This is my view hierarchy: rootView > scrollView > containerView > Textboxes, and so on...
However, as soon as I scroll, the contents of the ScrollView return to the sizes and positions that they seemed to have during portrait mode.
Aren't the contents of a UIScrollview supposed to Autogrow/shrink along with its contener? Is there a magic setting that I´m skipping in order to achieve such functionality?? Thanks in advance.
Related
I seem to be having issues with my UITableViewHeaderView not maintaining its position at the top when the device rotates. What seems to be happening is once the device rotates to landscape, the header completely disappears at the top. When I then rotate it back to portrait, the header seems to become massive and not reset to its original size. The header itself has imageviews and labels laid out inside the view using auto-layout.
Is there a way to adjust the header to stay where it is when the device rotates? I've tried looking at other questions but can't find a solution.
Some thing to try is to use UITableViewHeaderFooterView and put the content inside the contentView property.
I have a login page with a bunch of elements on it:
UIScrollView
Content View (UIView)
Email Text Field
Password Text Field
Login Button
Etc.
I need my app to run perfectly in both portrait and landscape orientations so I began setting up the different constraints to get AutoLayout working properly. I finally have all my UI elements in the right positions for both Portrait and Landscape, but the issue is that my scroll view scrolls too much and leaves a lot of empty white space at the bottom of the view when fully scrolled. I would like to fix this and keep things tight but I am not sure why. It's clearly the contentSize of the scrollview that is being set too large for the y value but I do not want to fix this with a workaround programmatically as I'm sure there should be the "correct" fix out there.
I've attached screenshots of the login page normal and fully scrolled (portrait and landscape) to help further understand.
Any help would be greatly appreciated. Thanks!
To adjust the height of scroll view, you need to do these two things:-
In the size inspector of scroll view, change the intrinsic size to "PlaceHolder".
Make sure you have added enough constraints that height of scroll view can be calculated. Since the contents in your scroll view are of static height, you can simply add a height constraint to your scroll view.
I'm not a 100% sure of this, but it could be that the view extends over the nav bar, causing the scrollview to have a much larger height than it should. IF that is the case, then autolayout-ing your view cause elements to be displayed everywhere else, other than the places you want them to be.
You'll need to disable Extends Under Top Bars in the attributes inspector.
I too had problem with scrollview my problem was that in iOS8 the scrollview was leaving some white space from top. I got crazy, finally I saw the solution by Ali Awais in this post and it fixed it
Here is the solution and link by Ali
I faced the same issue in iOS 8, following is solution I found: - Select View Contoller (in storybord) in which you have added the scroll view - In "Property Inspector" in "Layout" section un-check "Adjust Scroll View Insets"
White space scroll view
-anoop
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.
I've got a scrollview that allows the user to scroll between different pages and then tap on one to have it expand so that they can read the page in full, a little like how one changes tabs in Safari on the iPhone. Changing the frame size of each sub view is a bit of a pain when rotating as the scroll position is getting lost as the content size of the sub view has to change too. I was wondering if there was a more effective way of
resizing the views for entering 'viewing' mode or rotating the device.
The solution to your first problem is when you want to expand the view, pull it out of the scrollView then add it to self.view.subviews with an appropriate frame, then animate the frame to fill the screen. When done with it do the reverse, shrink it, then when its back to the appropriate size stick it back in the scrollView.
If for some reason this does not work - the scrollview is showing other stuff that gets moved when you remove the view, then instead of just removing your view from it, create a simple UIView of the same size as the view you will expand, and essentially replace the view you pull out with the "placeholder" view.
When building an interface in xcode 4.2 (using storybaord) what happens if the content is bigger than the screen in storyboard. I Can scroll text ok using scroll view but how do i set out images or text boxes buttons etc when i cant edit the physical screen size?
Thanks
If you have content in a scene larger than the fixed size in the storyboard, you can scroll within the scene with a two-finger drag. I think that is what you mean, please let me know if not.
From your comment you seem to be stuck at an earlier stage - actually telling the scene you want a larger area in the first place. To do this you have to add a UIScrollView (or UITableView in static mode) to your scene first, then add your text input boxes to that.