I am trying to add contentOffset to my ScrollView (which only scrolls horizontally and not vertically) so that the first element in the ScrollView is initially pushed over to the right by a bit. However, when I add contentOffset={{x: -20, y: 0}} now my ScrollView is scrollable in both directions which I don't want (I only want it to scroll in the horizontal direction).
I have tried using automaticallyAdjustContentInsets={false} but this disables the contentOffset.
I have also tried using padding but then the very right end of the ScrollView gets cut off
Is there any way to achieve this desired behaviour?
Related
I have a NSScrollView, which has NSClipView and vertical/horizontal NSScrollers in it.
Now I want to change the height of the vertical scroller so that it occupies only the top half portion of the scroll view. I can not change the height from the size inspector. I tried changing the frame. It didn't work either.
Can someone help me get through this problem? Thankyou in advance!
Since OS X 10.10, NSScrollView has a scrollerInsets property which should be able to position the scroller differently than the scroll view itself, if wanted.
Small world.
I ended up cooking a special component for the 8th pure SwiftUI/FRP incarnation of WhatSize.app
There are things Swift UI can't really do, so you have to wrap NSView objects as NSViewRepresentable and now they are available to a pure SwiftUI app.
scrollView.scrollerInsets = .init(top: 0.0, left: 0.0, bottom: 14.0, right: 0.0)
So the vertical scroll bars do not stomp over the drag and column resize icon on the bottom in yellow.
This allows WhatSize to display data just as Finder's "as Columns" does.
i use WMPageController as my one of viewcontroller, as we know , on iphoneX, scrollview will by default has a safeArea which constrain your content view in center ,that is top with 44 status height and 44 normal navibar height and to the bottom with 49 normal tabbar height and 34 home indicator height. then your scrollview can automatically be changed it's contentInset when scroll to the bottom to guarantee bottom contents of the scrollview will not be covered by home indicator, but when i use wmpagecontroller, it needs some uiviewcontrollers to make is easy to change vc in a single viewcontroller, then every single viewcontroller i test the scrollview in it , it runs with no problem,but when set to the umpagecontroller, i mean those controllers i set to doesn't be recognized its scrollView's contentInsetAdjustmentBehavior properly, when i scroll to the bottom, the outside vc(wmpagecontroller)'s home indicator is on my table cell's contents.
it‘s not normal , when i release my finger, the scroll indicator just clipped by the right bottom round corner ☹️
when it's normal it should look like this.....👍
who knows how to handle this situation ?
It's hard to tell from your description/screenshot if the content inset on your tableview is correct. If it is, you can adjust the scroll indicator insets in viewDidLayoutSubviews():
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
tableView.scrollIndicatorInsets = tableView.contentInset
}
Additionally, you adjust the tableView.contentInset before tableView.scrollIndicatorInsets as needed.
I am trying to have an image inside a ScrollView taking the full width of the screen while keeping its aspect ratio (I don't want a fixed background image). The answers in https://github.com/facebook/react-native/issues/950 seem to work for a View but not a ScrollView.
The null width/height trick just makes the image disappear. Setting the width using Dimensions.get('window').width does not work for some reason; it leaves some space either on the top and bottom or the left and right of the image depending on its aspect ratio.
I can't use Image.getSize() as the image is local and would rather avoid hard-coding the dimensions as I have many other images that need to be styled this way. I have tried many other combinations of flex, alignSelf, etc. but none seem to work.
Setting ScrollView's style={{width: "100%"}} works for me.
I have a problem which drives me crazy. I want to be able to zoom into a picture and scroll around. So I put a ScrollViewController onto my ViewController. And onto my ScrollViewController an ImageViewController. When I am setting the constraints I am always getting the note, that the Image will be different at run time. You can see where the yellow dotted lines show where the Image is going to be. I cant get the right constraints to get rid of this error so that my picture isnt cut in half. So when I am running the app in the simulator the Picture is always shifted downwards. The weird thing is when I am not using an Navigation Controller I dont have any errors. I dont know whether this is a bug or if I have a mistake in my constraints which I dont see. Is somebody here to help me ? To see the picture Click on "Screenshot xCode"
Thanks
Update: I uploaded a picture how it the view looks on the Scrollview and a picture when the Imageview is being added and it runs in the simulator.
i needed to delete the firs picture due to my reputation. But in the "screenshot2 xcode" shows the same problem
screenshot 2 xcode
screenshot 3 simulator
You need to add a view as a content view inside scrollview. You need to add following constraint to your contentview
- leading
- trailing
- top
- bottom
- width (equal to scorllview)
- height(equal to scorllview)
Its so confusing to add width and height constraint even if you add leading,trailing, top and bottom. But this width and height is actually for scrollview content width and content height.
Than add a imageview to contentview. give constraint as follow
- leading
- trailing
- top
- bottom
Hope this fix your problem.
Constraints must be as follow:
Per scroll view:
Align center x: Superview
Align center y: superview
Equal width: superview
Equal height: superview
Per image View:
Align center x: superview
Trailing space: superview
Leading space: superview
Bottom space: superview
Top space: superview
Height equal: make this the view height
Start all sizing from the top left corner in interface builder
I have a scrollview that I want to have disappear as it scrolls across a certain point on the screen. So as you scroll, the elements on the scrollview will disappear instead of covering up the elements behind it. But if you scroll back down, it reappears. How can I set a point on the screen that will hide the scrollview once it hits that point? I would like to accomplish this without having it "hide" behind another object. Thanks.
Almost forgot, it's all code, no IB used.
You could set the scrollView's clipsToBounds property to true?
Or, if that's not what you're trying to do, you'll need to intercept the scrollViewDidScroll: method and use the contentOffset of the scrollView to determine a threshold at which to make it (or its contents) disappear.
It's late in the day, these things happen. All I had to do was set the scrollview to proper size and location on the screen and it works great. Setting the ScrollView to the proper x and y and width and height fixed the issue. The upper edge makes the elements disappear when they pass the edge. Thanks again for the help, I'm going to figure out the contentOffset as I'm sure it will be needed one day.