How to shift views up/down when UITable view show and hide in dropdown iOS - ios

I want to shift views up/down when UITable view show and hide in dropdown. Please check following views.
When I click on red button the table view opens and closes. But when it closes the space remains unused of table view. I want to shift below contents to the upward direction and vice versa. How to achieve this? If we could do it by storyboard autolayout then please let me know how to set constraints?
Below image constraint partially working -
Below image constraint will not make any difference.

Set stack to your TableView and View. So, when you hide TableView it will automatically fill the space. Also, stack will help to to use less number of constraints to manage layout.

Related

ioS Scroll View with dynamic table View

I want to create a “ViewController” Scene with a “Scroll View” and in this view there should be a “Table View” at the top, 1 “segmented Control and 2 tables at the bottom.
The “Segmented Control” should switch the bottom table views.
Like in this picture:
My problem with this scene is that the table should have a dynamic height.
I need the bar over the complete page and not in the individual tables.
Is it possible to create such a scene and if yes, which constraints do I have to set?
I hope you can help me! Thanks a bunch!
tableView inside scrollView is a disastrous idea, because
tableView itself have its own scrollView.
Scrolling will be very sticky and it may freeze UI.
The best solution comes on my mind is to take single tableView and manage multiple sections.
The Green portion will be your first section.
Segment control will be second.
and blue section will be third.
In this way you can achieve both dynamic height as well as single scroll bar condition.
Let me know if it works.

Create Shazam Type UI ios Swift

I am trying to recreate a UIView I have seen in multiple apps, mainly Shazam. The top half of the screen has some interactive buttons, and the bottom half looks like a tableView with custom cells. When the bottom half is panned/swiped up, the tableView scrolls over the top half with velocity, much like a scroll view.
I have been researching this and experimenting for a couple days now. I have gotten close, but not quite there.
My last approach was a view that had a tableView inside it. When the view was panned, the view would move to wherever the finger moved it to, but then would not have any velocity afterwards. Also when the tableView was panned/swiped down, it wouldn't move the whole view down.
Before that I tried a scrollView that took up the whole length of the screen. That gave the desired effect, but the button wasn’t tappable, and you could scroll the view in the button area, which is undesired.
Does it utilize ScrollViews or is it using a tableView that acts much like a ScrollView somehow.
Here is the Shazam UI/UX I am looking to recreate:
The top portion has interactive buttons, and doesn’t scroll. The bottom half shows content and when scrolled, covers up the top portion.
Below is what I have tried so far: This one is the panning view, which sort of works, but doesn’t have velocity and the tableView doesn’t scroll the view back down.
Any thoughts on a direction I can take from here is greatly appreciated. I am using Swift.
Cheers
This sort of thing is perhaps best done with a collection view and a custom layout — you can have some items for which you set layout attributes absolute to the view, and others relative to the scroll content offset.
There's a great (if wandering) discussion of this and other techniques in the Advanced User Interfaces with Collection Views talk from WWDC 2014.
This is actually simple than it seems at first. Here's how you can achieve this:
Create a UIViewController (not a UITableViewController).
Add some buttons to the top area of the screen.
Add a table view spanning the entire view controller's view. Make sure the table view is on top of the buttons added in the previous step.
Configure the top cell of the table view to be transparent (by setting its background color to Clear). Set the background color on the table view to Clear as well. This way it won't obscure the elements at the top of the screen, unless the table is scrolled up.
Because your table view is now transparent, you'll need to explicitly set the background color on the table cells other than the top one.
Profit!

UIButtons not working in Scroll View

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.

iOS app shifted right and can't view full table

I'm having trouble setting a layout for my iOS app. The entire app is shifted right for some reason as you can see by the label and buttons which are in the middle of the scroll view.
I also can't seem to display the entire table. In the screen shot below "another Item" is supposed to have a checkmark and it is only visible if I shift the table in Main.storyboard far to the left where the actual label for the cell item is half visible.
I have a scroll view inside of the view controller and then a label and three buttons as well as a table view with table view cells.
Thanks to Lucas for the answer
Are you using Auto Layout with that storyboard? Looks like you might not have set your constraints up properly. You might also want to take a look at Xcode's new View Debugging functionality.

UITableView not following constraints

I have in the bottom of the screen a view containing 4 image views that I use as navigation buttons. That view is pinned to bottom layer by "0". Now my tableview is above this view and I have made a constraint of "10" from tableview to my "navigation view." I have two problems. When my tableview contains more rows than the screen can hold it puts the cells "behind" my "navigation view" even though I made the constraint it shouldn't. Now when I flip the screen to landscape mode it actually makes my navigation view disappear from the screen. I don't understand why as I pinned the bottom view to bottom layer. (2 questions)
Then of course my 2nd row decides to use much bigger font when I load in more rows, which is something I don't even want to bother you guys with yet, I think my simulator is playing tricks with me..
Anyway, I appreciate any help on my 2 problems above. Thank you
EDIT: Here I took some pictures:
http://i.imgur.com/LA9Spt0.png (this shows what i mean with the tableview pushing away the lower view even though the lower view is constrained to the bottom layer and the tableview has a constrain leading to the lower view (menu bar))
http://i.imgur.com/b6VoqFk.png Here what happens when I "pull" the tableview downwards to see more cells it blocks the upper label and top bar (which contains the logo I had to remove for reasons with the company) I tried to use :setBounces and setAlwaysVertBounces set to NO but then I can't scroll down the tableview when more cells exist.
(addition to img. nr 2)multiple cells makes the cells hide behind the lower menu navigation bar. I did make a constrain between the tableview and lower menu bar, shouldn't I be able to make the tableview "create" a scroll bar so u can scroll down instead of cells hiding behind the menu bar.
Thanks, any help much appreciated!
It sounds like you have some conflicts, or missing constraints.
You can see if you have constraints errors in the nib, in the 'view hierarchy' column in the left side of your nib, you will see a little red arrow..
Or that you have some conflict which you can see at the console when running you app.
Thanks

Resources