Tab bar disappear after segue - ios

After reading few topics in stack overflow about this problem, maybe someone will find where is my mistake: The tab bar in the destination controller disappear.
My source view controller is a Table view controller. when clicking on the cell There is a segue to Navigation view controller that linked to the destination view controller.
The segue is modal.
Table View Controller:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSLog(#"cell selected");
//doing some thing and call to the segue..
[self performSegueWithIdentifier:#"fromSearchToProfileSeg" sender:nil];
}
And the prepareForSegue:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([[segue identifier] isEqualToString:#"fromSearchToProfileSeg"]){
///searchVC.username = self.username;
NavViewController *navigationController = segue.destinationViewController;
ProfileViewController *pro = (ProfileViewController * )navigationController.topViewController;
pro.username = self.username;
}
}
And it's Look like:
Unfortunately, When clicking on the cell, the segue is working and the destination view controller is open, but the tab bar disappear. Does anyone know where is the mistake?

Make sure you don't have the option "Hide Bottom Bar on Push" in the attributes inspector for that view controller.

Related

Initiating a push segue results in `Pushing a navigation controller is not supported `

In my UITableView, when a user taps on a cell I initiate a segue like so:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[self performSegueWithIdentifier:#"MCExpandedSegue" sender:self];
}
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([segue.identifier isEqualToString:#"MCExpandedSegue"]){
// Opens item in browser
MCExpandedViewController *controller = (MCExpandedViewController *) segue.destinationViewController;
}
}
In order for the destination view controller (MCExpandedViewController) to have a navigation bar and a back button, I've embedded it in a Navigation Controller like so:
However, upon tapping a cell in the table in order to make this segue, I get the following error: *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Pushing a navigation controller is not supported'. Is this because it tries to segue to MCExpandedViewController but gets tripped up because it's contained within the navigation controller? How can I do this segue correctly?
Remove the navigation controller and segue
MCExpandedViewController directly.
Add this to viewWillAppear: in MCExpandedViewController.m
[self.navigationController setNavigationBarHidden:NO animated:YES];
First make sure your first view controller is embed in navigation controller.
MatchCenterViewController is in navigation controller.
No need of another navigation controller in different scene.

UITextLabel only updates on second selection of cell in Navigation Controller

I have a project with a TabBar Controller with a Navigation Controller and other View Controllers on it.
In my Navigation controller i have a sequence of 3 view controller and the last of them, DetailViewController, is being presented using a modal transition. I'm parsing strings between my 2nd and 3rd view controllers, but my labels displaying the information on the 3rd one only display after selecting a cell twice, and the information that shows is the one corresponding to the first selection of the cell.
Heres my 2nd view controller (ViewController) method prepareForSegue:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
titulo=[nomeEvent objectAtIndex:indexPath.row];
}
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
if ([segue.identifier isEqualToString:#"nextView"]) {
DetailEventViewController *myVC = [segue destinationViewController];
myVC.tituloEvento = titulo;
}
}
The property tituloEvento is declared in the second view controller's .h and in viewwillappear I set my labels text.
This might be happening because prepareForSegue is getting called before didSelectRowAtIndexPath:. Here is what I would do:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
if ([segue.identifier isEqualToString:#"nextView"]) {
DetailEventViewController *myVC = [segue destinationViewController];
NSIndexPath *selectedIndexPath = [self.tableView indexPathForSelectedRow];
myVC.tituloEvento = [nomeEvent objectAtIndex:selectedIndexPath.row];
}
}

UITableView with toolbar and multiple segues

I have a simple storyboard file with a table view inside a navigation controller. If you cick one of the cells it goes to the details view. Great.
Then I tried adding a toolbar button and hooking it up to my table view controller. The button and the seque seems to work fine, except now, when i click on one of the table cells, the modal view is triggered.
So it seems I have done something wrong, but I don't understand what.
// called by pressing the add button in the toolbar
- (IBAction)showAddEventView:(id)sender {
[self performSegueWithIdentifier:#"showAddEvent" sender:sender];
}
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.identifier isEqualToString:#"showAddEvent"]) {
AddEventVC *addEventVC = [[AddEventVC alloc] init];
// set some property
} else {
EventIndexVC *eventIndexVC = [segue destinationViewController];
eventIndexVC.eventTitle = [self.events objectAtIndex: [[self.tableView indexPathForSelectedRow] row]];
}
}

'segue' to same view controller from different table view cells

I have a tableview with five cells.
I would like each cell to segue to the same view controller, changing a property in the view controller depending on which cell was selected (didSelectRowAtIndexPath).
The main trick is that I'd like to use a storyboarded view controller for the segued to view controller.
Gratzi!
connect the view or tableview and next view controller directly by segue , but not tableview cell .
And then ,
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
//set any value depending on which cell was selected
//...
[self performSegueWithIdentifier:#"yourSegueID" sender:self];
}
about changing a property :
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
MyViewController *viewController = segue.destinationViewController;
[viewController setAnyValue:anyvalue];
}

How to open view controller from didSelectRowAtIndexPath within storyboard?

I have a storyboard with tabbarcontroller. One of tab bar has a tableview and I want that when the user tap in a row from tableview open a detail view. The problem is when I open detail view tab bar and navigation bar hides... In the storyboard I create the detail view as a new view controller, then I create a new file and referred it to the class of detail view .
The code in didselectrowatindexpath:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
detalleYouTube *dvController = [[detalleYouTube alloc] init];
[self.navigationController pushViewController:dvController animated:YES];
}
Thank you in advance!
This is kinda old but if someone needs to do this here's an easy approach:
You can use add a segue from the view in the tab bar to detalleYouTube, put an identifier to the segue and do this:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[self performSegueWithIdentifier:#"segueIdentifier" sender:tableView];
}
Another approach to this is not to use tableView:didSelectRowAtIndexPath but instead use prepareForSegue:sender
the way I did it was:
-(void)prepareForSegue:(UIStoryboardSegue*)segue sender:(id)sender
{
DetailViewController *viewController = [segue destinationViewController];
CustomObject *custObject = [arrayOfObjects objectAtIndex:[self.tableView indexPathForSelectedRow].row];
viewController.objectNeeded = custObject;
}
This example is based on the idea that your detail view controller is connected to your table view controller.
I presume you have the 'Detail' view as part of the storyboard (not in a separate XIB), if so you will need to place a separate NavigationController at the start of the 'Detail' TabBarItem seque.
This page has a good tutorial on what I think your trying to achieve:
http://maybelost.com/2011/10/tutorial-storyboard-in-xcode-4-2-with-navigation-controller-and-tabbar-controller-part1/
Also check these links to a more in-depth Storyboard tutorial:
http://www.raywenderlich.com/5138/beginning-storyboards-in-ios-5-part-1
http://www.raywenderlich.com/5191/beginning-storyboards-in-ios-5-part-2

Resources