UITableview Push Detail - uitableview

in my application i have a table view push to a view controller but i want to have the table view push to a new table view how would i approach this?
this is how i am performing the segue now
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([[segue identifier] isEqualToString:#"ShowDetails"]) {
DetailViewController *detailViewController = [segue destinationViewController];
NSIndexPath *myIndexPath = [self.tableView indexPathForSelectedRow];
int row = [myIndexPath row];
detailViewController.DetailModal = #[_Title[row], _Description[row], _Images[row]];
}
}
this work when pushing to a view controller but not a table view controller how do i make it go to a new table view?

Apparently you're doing the Geeky Lemon Tutorial found here. When you create the second tableView make sure you set the custom identifier to "DetailViewController".
Hope it helps.

Related

How to use prepareForSegue for multiple Tableview Controllers

I am having three table views A,B,C . The flow of view is like this:
table A ,click on a row --->table B, click on a row----Table C
I am using the following method to send the data from master view A to detail view B.
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.identifier isEqualToString:#"showDetailFinal"]) {
NSIndexPath *indexPath = [self->ListView_A indexPathForSelectedRow];
DetailView_B *destViewController = segue.destinationViewController;
destViewController.detailStatements = [dataArray objectAtIndex:indexPath.row];
}
}
and I have the same method again to send the data from detailView_B to moreDetailView_C
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.identifier isEqualToString:#"showDetailFinal"]) {
NSIndexPath *indexPath = [self->DetailView_B indexPathForSelectedRow];
More_DetailView_C *destViewController = segue.destinationViewController;
destViewController.detailStatements = [dataArray objectAtIndex:indexPath.row];
}
}
I am using the modal segues instead of push. The problem is that,when I go to table B from table A, I see data in table B.
But when I go back to table B from table C, I do not see any data in table B.
The view did load method in table B is :
- (void)viewDidLoad {
[super viewDidLoad];
NSLog(#"the name is %#",detailStatements.name);
// here when I come from table A, name is not null
//but when I come from table C,name is null.
}
Is it possible to use common segue identifier for all 3 table views?
Kindly tell me the possible way to handle this?
From your comments you need an unwind segue and not the normal segue you are using for going backwards.
This might help Storyboard: Control-drag from a bar button to the Exit item
Or add an action to the buttons to simply dismiss the view controller.

Segues not working (Table view/navigation controller/tab controller)

I am writing an iOS app that uses the service Parse. When I tap on a cell, it doesn't segue as I would expect. It appears that my "prepareForSegue" method is not being called. I used breakpoints to determine this, and the NSLog never outputs anything. Here is my method:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
NSLog(segue.identifier);
if ([segue.identifier isEqualToString:#"showObjectDetails"]) {
NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
//OfferDetailViewController *destViewController = segue.destinationViewController;
PFObject *object = [self.objects objectAtIndex:indexPath.row];
[segue.destinationViewController setObject:object];
}
}
The segue name is "showObjectDetails" if it matters, and it's coming from a list view. I used the Push selection segue. I have made sure that the Custom Class is set correctly in Interface Builder. I am using a Tab Bar controller, that references a NavigationController, that then displays the tableview.
Make sure that the Segue Identifier has been set in the Storyboard, as below.

Can i use same detailedViewController with different segue variables

this is my problem. I can perfectly show a detailedViewController came from a table view, but i got 2 more tableview that i want to make it seem in detailed.When i gave it same variables - since every things that came same - it still doesn't go to the next view controller.I checked segue identifier aswell and i really don't want to make a new detailed controller.
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([[segue identifier] isEqualToString:#"showDetail"]) {
// Get destination view
detailViewController *destViewController = [segue destinationViewController];
NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
NSInteger tagIndex = [(UIButton *)sender tag];
destViewController.recipeName =[[self.content objectAtIndex:indexPath.row] valueForKey:#"recipeName"];
destViewController.recipeDetail =[[self.content objectAtIndex:indexPath.row] valueForKey:#"recipeDetail"];
this is how i pass the data.They are exactly same with a small difference. The content of the content array.
You can go to the same view controller from multiple other controllers. You may be able to do this by simply creating the segue from the appropriate cells in each table. The way I've done it is to create a segue from each table view controller to the "detail" view controller, and then perform the segue in code when the appropriate cell is selected. Keep in mind that when creating segues in IB, there is a difference between creating them from table view cells and from the view controllers themselves.

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];
}
}

Dynamically showing TableView or DetailView

From my TableView I dynamically want to show either a TableView or a DetailView (new segue), based on the cell's content. I setup two segues from the TableView to different DetailViews and one segue from the TableViewCell to the TableView.
I have almost completed the implementation using performSegueWithIdentifier: (see below), but there is one struggling issue remaining: after I call [self dismissModalViewControllerAnimated:YES]; on the DetailView it returns to an empty TableView . I assume because the Storyboard segue from the UITableViewCell is performed. By clicking the back button I return to my original (parent) TableView data.
Any suggestions for this work?
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
NSLog(#"%s", __PRETTY_FUNCTION__);
NSString *type = [[self.dataController objectInListAtIndex:[self.tableView indexPathForSelectedRow].row] valueForKey:#"cell_type"];
NSLog(#"cell_type: %#", type);
if([[segue identifier] isEqualToString:#"DetailSegue"])
{
UIViewController *detailViewController = [segue destinationViewController];
detailViewController.game = [self.dataController objectInListAtIndex:[self.tableView indexPathForSelectedRow].row];
} else if ...
} else if([[segue identifier] isEqualToString:#"TableViewSegue"]){
if([type isEqualToString:#"TableView"]){
//Create child ViewController, a custom ViewController with custom initWithId:Title:
CategoryViewController *categoryViewController = [[segue destinationViewController] initWithId:categoryId Title:categoryTitle];
}
}
}
I would create in my tableview multiple cells. Each with its own identifier. Then connect each cell to its own detailviewcontroller. You can also connect a cell to its own view controller (creating drill down functionality for only specific cell).
Thats all...

Resources