I used ShowDetailSegue to push a DetailVewController from another DetailViewController. there is no issues. But my need is to push to a DetailedViewController from a TableView in another DetailedViewController.
I used the below code for pushing:-
PushUpExerciseViewController *pushUpObj = [self.storyboard instantiateViewControllerWithIdentifier:#"PushUpID"];
[self presentViewController:pushUpObj animated:YES completion:nil];
After using this code in my TableView DidSelectRowAtIndexPath the MasterViewController is missing. i need both Master and Detailed ViewControllers. How to push from TableView in DetailViewController to another DetailViewController Programatically
Simply push to View Controller.
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
DetailVewController *objDetailVC = [self.storyboard instantiateViewControllerWithIdentifier:#"DetailVewController"];
//Pass the data here to DetailViewController
[self.navigationController pushViewController:objDetailVC animated:YES];
}
As you told you need to push DetailedViewController from another DetailedViewController instance on TableViewCell selection. In this case you need prevent the infinite loop of push.
Flow
Master (Push) -> Detail (Push on didSelectRowAtIndexPath ) -> Detail
Related
I have a tableView. My tableView cells do have a detail accessory.
My question: How can I push another view controller when the detail button is presses.
When I normally press the cell, my ViewController1 opens. But when I tap on the little i on the right of the cell, I want to push a different view controller.
How can I do this?
it is just like DidSelectRow u need to modify DidSelectRow to accessoryButtonTappedForRowWithIndexPath
-(void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath
{
// if u using .Xib
yourviewcontrollerName *vie=[[yourviewcontrollerName alloc]init];
[self.navigationController pushViewController: vie animated:YES];
//// if u using storyboard
[self performSegueWithIdentifier:#"yoursequeName"
sender:self];
}
you need more information use this link Pushing to a Detail View from a Table View Cell using Xcode Storyboard
Use this code it works
-(void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath
{
// Push new View controller here
UIViewController *objVc=[[UIViewController alloc]init];
[self.navigationController pushViewController:objVc animated:YES]
}
I am new to Objective-C.
It has TableViewCell and the TableView on the ViewController like the following picture.
I want to change the View to another Viewcontroller when I click the TableViewCell.
But it seems can not use the performSegueWithIdentifier to change the View in didSelectRowAtIndexPath without using UINavigationController , The error log like the following:
Push segues can only be used when the source controller is managed by an instance of UINavigationController.'
Is there has another way to change the View to another Viewcontroller when I click on the TableViewCell ?
Thanks in advance.
In Interface Builder(storyboard) click the following:
Exactly what the debugger says: Push segues can only be used when the source controller is managed by an instance of UINavigationController.' Then you'll be able to push segues.
U can present view controller using this
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
yourViewController *vc = [[yourViewController alloc]initWithNibName:#"yourViewController" bundle:[NSBundle mainBundle] ];
[self presentViewController:vc animated:YES completion:nil];
}
For some reason my navigation controller isn't pushing properly.
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSLog(#"HERE!");
MyViewController *vc = [self.storyboard instantiateViewControllerWithIdentifier:#"myVC"];
vc.labelText = [self.myArray objectAtIndex:indexPath.row];
[self.navigationController pushViewController:vc animated:YES];
NSLog(#"Pushed");
}
The output is:
2014-02-17 12:41:47.187 TableViewTesting[37532:70b] HERE!
2014-02-17 12:41:47.189 TableViewTesting[37532:70b] Pushed
So it's all running fine, but I still just see my initial view controller even after tapping on a cell.
Is the view controller from which you are calling this code embedded in the Navigation Controller? If it's not, then nothing would happen when you call pushViewController method.
Go to your Storyboard, select the initial view controller, then from the top bar Editor > Embed in > Navigation Controller and try again.
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
I am trying to show detailed UItable view when clicking on row. I used
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
// Navigation logic may go here. Create and push another view controller.
// AnotherViewController *anotherViewController = [[AnotherViewController alloc] initWithNibName:#"AnotherView" bundle:nil];
photoListViewController = [[PhotoListViewController alloc]initWithNibName:#"PhotoListViewController" bundle:[NSBundle mainBundle]];
[self.navigationController pushViewController:photoListViewController animated:YES];
[photoListViewController release];
// [self.navigationController pushViewController:anotherViewController];
// [anotherViewController release];
}
This PhotoListViewController is an empty UITableViewController. As I know UITableViewCOntroller has a navigation controller implemented and I don`t have to create navigation controller. But When I clicked on row it does not navigate to second view.AM I have to make some connection on nib file?I only created this PhotoListViewController in File->New->UIViewCOntroller and selected UITableView.
EDIT : SOLVED
I solved my problem.I should use UINAvigation object.I thought that UITable has it but there was no ))