I cannot scroll below that red line, it seems, that UIScrollView automatically cuts it out. How can I make it not cut it out?
contentView.translatesAutoresizingMaskIntoConstraints = true
This line seems to fix it, at least in my case. Content View is a child of Scroll View.
Related
I'm trying to make a ScrollView so that its size adjusts to the size of the text. I placed all the necessary constraints
, but when the application is displayed on the simulator, the content view starts from the safe area and also ends up to the safe area. Although I have pinned scroll view to superview and content view to scroll view.
I want the content to start not from the safe area like here ,
but from the start of the screen like here
in other words, I want to remove the blue bar from the top and bottom
Do you have any ideas how to do it?
Sometimes UITableView & UIScrollView can still show safe area even though you attach your View to top of Super View. You just need to add one line to solve this issue but make sure your ScrollView is connected to superView not safe area at the top.
Add scrollView to your ViewController and in viewDidLoad() just write:
scrollView.ContentInsetAdjustmentBehavior = .never
Check this answer for further details: Make UITableView ignore Safe Area
I am not sure why there is so much white space on the top of UIScrollView. If I switch the tabs and come back to this tab again then everything is okay. See the image below:
How can I fix that?
UPDATE:
The constraints on the first UILabel which is the description are shown below:
The fix is to implement the following line of code after in the viewDidLoad;
self.automaticallyAdjustsScrollViewInsets = NO;
I have a ViewController with a view that contains a ScrollView and a PageControl positioned at the bottom.
What I noticed however, is that the ScrollView already has its own set of 3 dot indicators. So, just for the sake of testing, if I move around my PageControl bar, I can actually see two sets of dot indicators.
I have my IBOutlet set to my PageControl, so the dots get updated as I'd expect. However, the dots on the ScrollView don't change (and there are always 3 of them).
Why does the ScrollView already have its own dots? I tried unchecking "Show horizontal scrollers" but this did not get rid of the dots.
I guess why question is two-fold: How could I remove the dots from the ScrollView since I really only want the PageControl? Secondly, what is the purpose of having those dots on the ScrollView itself?
To be clear, I've already unchecked the Show horizontal and vertical scrollers in Interface Builder. I have also disabled them programatically:
scrollView.showsHorizontalScrollIndicator = NO;
scrollView.showsVerticalScrollIndicator = NO;
Thank you in advance!
The UIScrollView does not have dots. Maybe you added two UIPageControls accidentally. If you show more code maybe we can help but all I can tell you is that a UIScrollView is not the source of the dots.
It might be a silly question.
I'm trying to set left/right margins like the attached picture. I succeeded to implement it by adding UITextView to UIScrollView.
However, I could achieve almost everything I want with UITextView alone. For example, with UIScrollView, when I manually change the text of UITextView, it automatically scrolls to bottom regardless of setting its .scrollEnabled to No.
It would be perfect if a scroll indicator of UITextView appears outside UITextView.
In the attached picture, let's say the red box represents the entire UITextView. I tried to change UITextView's scrollIndicatorInsets property, but a scroll indicator can be moved only inward to be visible.
Several apps such as Pages, aWriter, Plaintext achieve this feature.
Could you give any suggestion?
Thank you!
I
You can set the scroller right inset value of the UITextView to negative value and disable the clip subview option to achieve your require. No other scrollview is needed.
Alternatively you could set the Right contentInset property.
UIEdgeInsets insets = textView.scrollIndicatorInsets;
insets.right += 5; //add what ever is your margain
textView.scrollIndicatorInsets = insets;
I have a vertically-scrolling UITextView that fills the width of the screen. I need the text view to have margins (contentInset) of 20 pixels on the left and the right. But for some reason, I can't get the right-hand margin to work, either in Interface Builder or in XCode.
The reason I can't just make the text view narrower is because I am adding a subview which needs to run the full width of the screen. Also, I can't turn subview clipping off, because it plays havoc with a load of other elements on the screen.
Anyone know why the contentInset property is not affecting the right margin?
Thanks!
You could add an intermediate view that can be the superview to your text view and what was previously it's subview.
New View with Frame(0,0,width,height)
->TextView with Frame(20,0,width-20,height)
->Subview with Frame(0,0,width,height)