2 uitableviews in 1 and make their heights change dynamically - objective-c

I'm trying to accomplish the following. I got 2 uitableviews in a single uitableviewcontroller and at the bottom of the view I have a button. As soon as I click on that button (width of table view) it moves (with animation) to the center of the screen. Now I want the second uitableview to move with it and the first one (was fullscreen before) to shrink. So that at the end I'd have 2 uitableview showing data at the same time.
Clicking again on that button would, you guessed it, move it to the bottom of the screen, hiding the second uitableview so that the first one is in fullscreen again.
Any hints/ideas/code how I could accomplish that?

You cannot use a UITableViewController. You need a UIViewController, throw in 2 UITableViews, make them #propertys of the view controller, and handle their data source and delegate methods as normal.
Then when you press the button, you can change the frames of the two table views just as you change the frame of any UIView.

Related

Animate view and set button backgroundimage conflict

I am making a type of drawer animation for iOS where a button tap in one of my views will expand that view over the other views from the bottom up. All is well, except when I want to change the button image after animation. The animation completes but then returns the view to its original position when setting the button image.
Things I have tried:
Using CGAffineTransformMakeTranslation instead of setCenter; this works perfectly, except I want to also add a panGestureRecognizer to interact with the drawer, present, and dismiss it. The transform doesn't seem to play well with this interaction
Adding the buttons programmatically thinking maybe AutoLayout is fussing with this
UIView beginAnimations as well as UIView animateWithDuration and completion block
Setting breakpoints and verifying that the movement of the view is reflected in the frame of the button before the image is changed; button frame is not still in original position, but has supposedly relocated with the view
It shouldn't matter, but my project is using TabBarController. I made a simpler version of what I'm trying to do with just the one view controller and had the same issue. The green view extends beyond the frame of the view controller's view so that when it moves up it reveals what is off-screen.
example: http://i.imgur.com/tRou0Js.png?1

Using UITabBarController in a subview

I have a view in my app to which I want to add tabs, but only in the lower half of the view. The top half of this view is supposed to be fixed. Something like this:
By pressing the tabs on that UITabBar I want to toggle the contents of the lower half, but without changing the contents of the upper half. I used tab bars before with UITabBarController, but using storyboard I can't add the controller because it creates two completely different views. How can I do this?

view on top of tableview dissapears

I have a problem with my tableview. My first problem is that I have a tableview with a view on top. In this view there are 3 buttons. I am building this using story board.
My problem with this is that what I scroll down, my view disappears. How can I set this that this view always stays on top? At the moment you can see this view as the 'first cell'.
Kind regards
If you look at the view hierarchy on the left hand side you'll see that your header view is a subview of the table, so it scrolls with it.
From that hierarchy view drag it out of the table view so that it's at the same level.
Also, resize your table so that it starts underneath the view with the header bar.
Tim
What if you select your view in Interface Builder, then go to Editor->Arrange->Send to front?

How to prevent a UIView from consuming user input

I have a simple view hierarchy example.
Obviously the main view space is the primary space the user will interact with. At the bottom I have tabs that can pop up to indicate to the user where he/she is in the progression of the app. Normally, these tabs only take up the space indicated by the "Custom Tabs" rectangle at the bottom, but they can expand all the way up to fill the "Empty Space" box.
In order for the tabs to still be clickable, I had to make the tab view's frame the full rectangle containing both the "Custom Tabs" space and "Empty Space" space. What this results in is that "Empty Space" not being interactive to the user when the tabs aren't popped up, because the input is basically being consumed by that UIView, and not forwarded through the rest of the hierarchy.
I suppose the root of this problem is that both "Main View Space" and the "Empty Space + Custom Tabs" are both subviews of the main window.
Is there a way I can tell the system to forward the user input to the sibling views if the user didn't actively tap on an interactive element? For example, doing something with the touchesBegan, touchesEnded etc. methods that would indicate to the OS that this view did not use the input.
EDIT
Here's another version of the view, demonstrating the tate of one tab being open:
EDIT2
After some simple testing, it would seem that the default behavior is that the top most view gets the input first. This applies even if you have a clear UIView on top of a UITextField. The clear UIView will consume the input, preventing the UITextField from being editable
EDIT3
The way the tabs are supposed to work is the user can tap on a tab (sized as in the first picture), and then it will expand to display a thumbnail view associated with that tab (as in the second picture). The user can then optionally tap the tab once more to close it, and return the size to the original picture. In order for the tab to be clickable when it is open, I have to have the containing view be basically large enough to contain all 4 tabs as if they were open. This results in a lot of empty space in the containing view. This empty space results in essentially dead input space on the screen. If there were a button in the main view space that is covered by the empty space, the user would not be able to click on it. I would like to be able to avoid that behavior, and have that button covered by the empty space still be clickable.
Rather than trying to "forward" touches, I would modify your layout so that the tab view is only as big as the tabs, and change it's .frame to be the larger rectangle in code only when you need it. For example, when a tab is clicked:
CGRect tabFrame = tabView.bounds;
tabFrame.origin.y = top_of_emptySpace;
tabFrame.size.height = height_of_emptySpace + height_of_tabView;
tabView.frame = tabFrame;
then you can add the content you need. when you need it to go away, remove the content then do :
CGRect tabFrame = tabView.bounds;
tabFrame.origin.y = top_of_tabView;
tabFrame.size.height = height_of_tabView;
tabView.frame = tabFrame;
There might be some tweaking required to make the content show up as you like, but this way, when the tabs are minimized, you won't have to do anything extra to make the main view respond to touches correctly.
Ok, this is the way I would do it:
The RootViewController has two views, its main view which takes the whole screen, the one that is added to the window. And the tab view.
Then I would add another view controller (a UINavigationController ideally) to the RootViewController and I would have its view added as a subview of the RootViewController's view.
Any change performed, such as pushing new view controller or anything, would be done to the child view controller.
That way, your tab view would always be showing. To open a tab, you could create a new view that would show on top of the tab bar using an animation or something similar.

How do you create a slide out tableView on the right instead of the left of iPad Master-Detail Application?

If you create an iPad Master-Detail Application and use Portrait orientation, it gives you a slide out tableView on the left.
1. How do you make it to show on the right?
Also, in the landscape orientation, it is split in into two views.
How do you make it so that it will be the same as the Portrait View, like slide the TableView out?
Is it possible to adjust the size of the Detail View?
If you dont want two views in landscape, why do you need a splitView at all? You can just have a UIView with a popover button on the top bar. Then you can add the tableviewcontroller to the popover. To show it to the right you can define the rect or use the rightbarbuttonitem to add the popover.
You can have master on right by passing masterviewcontroller as second parameter to the array assigned to splitViewController.viewcontroller. However, you cannot resize the master and detail views. Hence you will end up having a bigger masterView than the detailview.
Looking at limited functionality of UISplitViewController, it may not be possible to have master on right(properly working as per your requirements). You can have your own controller to get this done or try using opensource options like MGSplitViewController.
you may also like to look into this discussion