The famo.us tutorials shows how to use a ScrollView which doesn't seem to provide a horizontal scrolling method.
So I was wondering how do I implement horizontal scrolling for my famo.us app (my personal website).
Yes. To enable Horizontal scrolling you simply pass the direction option to the Scrollview constructor..
var scrollview = new Scrollview({
direction: Utility.Direction.X
});
Utility.Direction.X actually is a pretty way of saying 0. So this will work as well..
var scrollview = new Scrollview({
direction: 0
});
Good Luck!
Related
I want to embed some SwiftUI in my UIKit-based UI, and unfortunately Apple doesn't provide UIHostingView, only UIHostingController. Can I more or less ignore that controller and just use its view, or do I really need to add it as a child view controller as well? What happens if I don't?
The problem is that finding the parent view controller can be difficult in some contexts. UIView itself doesn't know anything about view controllers, so I'd have to come up with my own way of keeping track of which is the "current" view controller. And I'd rather not do that unless it's actually necessary.
So far in my experiments it's working fine without adding UIHostingController as a child. Device rotation is handled appropriately, and SwiftUI's dark mode override (.colorScheme()) even works through the embedding.
With UIHostingController(rootView:) you just pass in a SwiftUI View.
You can treat it as a UIView by doing:
let myView = UIHostingController(rootView: Text("Hello world!")).view
And then add it as a subview for example:
let parent = UIView()
parent.addSubview(myView)
After adding a combined gesture to a view, a TextField inside the view would no longer respond when I would tap into it to change the text. I discovered this after adding a custom combined gesture - where I used a long press to start things before dragging. (Note: things still worked if just a drag gesture was added. Not sure what is particularly different between these two cases.)
The combined gesture:
let combined = longPressGesture.simultaneously(with: dragGesture)
The gesture was added to the view with:
.gesture(combined)
I got things to work by adding an onTapGesture{} to the TextField. Didn’t have to put anything into the action. Seems like a side effect whose behavior could change in the future. Appreciate any comments on if this makes sense or other ways to handle.
TextField(“Enter Text”, text: $myText)
.textFieldStyle(RoundedBorderTextFieldStyle())
.onTapGesture {}
In case one would have this issue with a drag gesture, you can set the minimumDistance. This would still register the tap on the textfield to edit it.
DragGesture(minimumDistance: 30, coordinateSpace: .global)
Adding a drag gesture in SwiftUI to a View inside a ScrollView blocks the scrolling
Many apps have an intro view that has fullscreen pages with a dot indicator at the bottom. Sometimes it is used to gather same basic information, sometimes to introduce the app features.
How can I realize that?
I tried the ScrollView with a horizontal setting. The issue is to set up the content to fit the screen and have the edges snap on scroll. Second issue is the have a dotted indicator that highlights the current page.
you need to wrap UIPageControl with UIViewControllerRepresentable.
Is it possible reverse the scroll position in a scrollview so it scrolls from the bottom up?
It would be helpful to do this because it would allow me to lay the scrollview flat and stand the surfaces up and still have the first surfaces at the front.It's a bit hard to explain so I have this image Basically I am trying to scroll through these surfaces like a filing system. Is there perhaps a better way to simulate this?
I have added the UIScrollView into the COCOS2D game engine using
[[[CCDirector sharedDirector] openGLView] addSubview: tempScrollView];.
On that scroll view I have added a image view and a buttons. My problem is that the scroll view is scrolling vertically only. I want the UIScrollView to scroll horizontally only. Also I want the images to be rotate as well. I have tried the view transform property but its not working in my case.
Does any body know how to do this in cocos2d?
Horizontaly only ? try to change contentsize. e.g.:
ccp(5000,winsize.height)