swift uitableview moves up after unwind segue - swift

I have a custom uitableview inside a uiviewcontroller. A segue to another tableviewcontroller will happen every time a cell is tapped on. I also have a back button on the other tableviewcontroller which allows users to segue back to the original viewcontroller. The problem happens when the unwind segue happens. After I get back to the original viewcontroller, the first cell of the tableview would be hidden right below the navigation bar, so the tableview bounds have changed I'm guessing? I have been looking everywhere but am unable to find a solution, please help! thanks in advance!

Related

Manuel segue 'Show' does not call ViedDidload when returning to parent viewController?

I have a viewController containing a UITableViewController. This UITableViewController is populated by an array. When User presses populated cells they segue with a segue set to 'Manuel Segue : Show' this creates a back button UINavigation bar item. Inside this viewController the user is able to add Items to the array populating the parent UITableViewController. The problem is that when i segue back using the UINavigationbarItem it does not call viewDidload on the UITableViewController, there by not updating the UIViewTableCells. I have to close application to make it call viewDidload... How do i make it call ViewDidload when returning from the Manuel segue show? All help appreciated.
The pushing view controller is not unloaded when another view controller is shown above. As viewDidLoad: is only called once in the view lifecycle, this would then not be called when the segue is unwound.
Updating your tableview in viewWillAppear: or viewDidAppear: would cause this to be called whenever this view is displayed.
viewWillAppear would perhaps be better if you don't want to show the user the table reloading when not needing to asynchronously load data.
Read more on iOS view controller lifecycle here:
https://developer.apple.com/library/ios/referencelibrary/GettingStarted/DevelopiOSAppsSwift/Lesson4.html#//apple_ref/doc/uid/TP40015214-CH6-SW3

UITableView cell needs double click

I have a UITableViewController. Each cell in the table has a segue to present another UIView modally.
When I click on a cell in the UITableView, it brings up the other UIView.
But I put the UITableViewController in a Navigation Controller, nothing happens on the first click to the cell, and the UIView shows up on the second click.
Does anyone know why putting the UITableViewController in a Navigation Controller cause the first click to do nothing?
EDIT:
It seems that the focus is not initially on the table view. When I first click the cell, the focus on the tableview, and the second click goes to the cell.
I used storyboard.
Here're some screenshots:
This is the setup of the views
This is how the table cell is connected to second view controller

Save and Restore UIViewcontroller when back button is pressed

I have two UIViewControllers. In first UIViewController I have a UITableView as a subview. When any one of the UITableViewCell is selected, a UIView(as a subview) will be displayed, which have 9 buttons. When any one of the button is pressed, Second UIViewController will be presented. When user press custom back button on second UIViewController, First UIViewController have to be presented with all previous selected UITableViewCell and corresponding subviews open. How to achieve this. Is there any process to save UIViewController's state at a desired time.
Any suggestion will be greatly appreciated.
If your are using a Navigation controller, navigating from one controller to another, your parent view controller will not be deallocated. Hence you can maintain state of that first view controller by means of properties or something else. When viewWillAppear is called for that controller, you can make use of that and update the controller accordingly.

TabBarController called by a TableViewCell in another TabBarController

I was wondering if it is possible to have the following:
One TabBarController with two buttons containing a UITableView in each one.
Then, if one of the TableView cells is clicked, I would like to push to a new TabBarController with a different set of 4 buttons containing other table views.
Can anyone point me in the right direction?
The first thing I tried was set up the first TabBarController with the UITableView under each button. But when I added the second TabBarController to be triggered from a clicked tableview cell, what I got was the first Tab which contains the 2 buttons, and on top of that, the second tab containing the 4 buttons.
I would like the second TabBarController to replace and leave behind the first one.
I hope I explained myself well enough, thank you for your time.
You should change your push segue to a modal segue.
To go back you are going to need to implement a return button in your destination viewController:
- (IBAction) dismiss:(id)sender
{
[[self presentingViewController] dismissViewControllerAnimated:YES completion:nil];
}
(note that you must do this in code - you cannot draw a segue line to go back)
At the moment you must have a navigation controller involved in your push segue. When you change to a modal segue you can remove the navController, it won't play a part in the navigation.

Segue not performing

I'm currently facing something I find rather strange.
In my storyboard, there is a TableViewController filled with static cells.
I would like to perform a simple segue (a push to another view controller) when I select one of the rows.
So I "ControlDrag" from the concerned table cell to the sibling controller, but when tap one the cell, nothing happens. Next to that, I did try assigning the segue triggering to the accessory view of the cell (a disclosure button). And in that case, the segue is effectively triggered.
So here is my question : Should I use the "programmatic way" to handle the tap on the cell (tableview delegate methods and manual segue performing), or is there something I'm missing in the interface builder? And btw how could we explain the behavior difference with the accessory button view ?
Here is two screenshot
Cell selection that should trigger segue
And, the accessory action which performs the segue
I finally found what the problem was. I had a gesture recognizer attached to the view controller, and it was catching the tap event on the cell.