I would like to create a level menu in swift.
I have a ScrollView and an image inside the ScrollView .
I would like to add a button which stays at the same place when the ScrollView scrolls.
If I put the button on the same level as the Scrollerview, it would work but the image inside the
ScrollView covers the button. If i put the button inside, it starts to move as i scroll.
How can i scroll the image and leave the button at the same place?
You should put the button on the same level as the ScrollView but above in the element list.
Related
So I have a horizontal scroll view at the bottom of my screen which contains child views. I would like to drag a view from the bottom and snap it to a defined position on the top. But while dragging the view, it only moves about inside the scroll view. Is there any way to exit the scrollview and get the view outside it?
Layout of the app (I want to take the items from the bottom and snap them to the positions on top):
When you try moving views coordinates with drag, it will only move on its superview, i.e. your bottom scroll view.
If you wanted to drag your button outside of your scroll view then you need to have a trick here.
When user started dragging the button, hide it.
Add the same layout button on main screen on exact position.
Move the newly added button on main screen where ever you want.
Once you drop it, remove the old scroll view button.
It will look like you dragged the same button on main screen but under the hood it was a different logic.
I have a view where content is supposed to scroll over a few elements. One of which is a button. What I did is place the button and all background elements, and then created a scrollview on top of that.
However, the touch events now (obviously) go to the scrollview, and not to the elements in the back. Is it possible to enable interaction through the empty parts of a scroll view?
Screenshot here:
There is a scrollview on top of e.g. the "next" and "edit" buttons. but I'd like these to be clickable anyways.
Thanks.
I'm going to assume that the content you want to scroll is in a subview. ScrollViews always serve as the first layer of any scrollable UI. Put scrollview in your subview then UIView over your ScrollView and over that add your elements.
I'm creating an app that has hundreds of view controllers in interface-builder. Each of these view controllers has a button with a code number. When the button is pressed I want the button to expand and show a few lines of text describing the code number. The problem is that the button is placed within a subview that acts as a frame for the button. Therefore, the expanded button size is going to be constrained to that subview and the text will be cutoff. Is there a way for me to programmatically remove the reference to the sub-view? I can do this in interface-builder, but like I said there are hundreds of these view controllers.
Instead I removing it you could expand the subView's and the UIButton's width. That would allow the button to expand as you'd like it to and you would not have to remove the subViews.
I have a Scroll View with a View (content view) inside of it. I've added two buttons to test. The Scroll View scrolls fine but the buttons within the content view are not clickable. I've seen plenty of posts saying this issue happens when they programmatically add UIButtons to the View, but I am not doing this. Here is my exact process:
Drag the Scroll View onto the main view. Add 4 constraints
Drag the Content View onto the Scroll View. Add 4 constraints.
Add 2 Buttons (one high and one low to test scrolling) to the Content View.
This is all I am doing, no code at this point. Is there anything else I have to do to allow the buttons to be clicked? Here is a screenshot of my xib:
Update:
When hooking the button up to a simple IBAction and logging a message, it turns out it IS being pushed and working properly. However, when the button is pushed, the button isn't changing colors like it should (its "pressed" state is not appearing). Any ideas why?
First make the button to custom type
Select button from storyboard then on right attributed inspector change its "state config" to whatever you need like Highlighted, selected, Disabled and default and choose the colour for each state.
Now you can see the colour change on that button.
A UIScrollView first needs to know whether or not you are going to scroll before letting the touch pass to its child views. If you want the child views to get the touch immediately, set the UIScrollView's delaysContentTouches to NO.
I have a ViewController that has a ScrollView that will display a article.
The user can rate it with a like or dislike.
I need to put a fixed footer Label that will display these buttons.
That label will be displayed above the ScrollView, just like the NavigationBar.
Right now I am not able to put a button inside the label and when I put the label I cannot scroll anymore.
Any one knows how to do this?