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.
Related
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.
I have 2 view controllers - One with a collectionView displaying images, the other it's corresponding detail view - pretty basic. The problems is items in collectionView are not selectable for some reason (touch but nothing happens). Also, I am not using a nav controller to embed the collectionView VC in, prefer to use an unwind segue with custom button - will this work?
I made a connection from the collectionView Cell to the Detail VC.
In prepareForSegue
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.identifier isEqualToString:#"detailSegue"]) {
LPDiaryDetailViewController *destViewController = segue.destinationViewController;
NSIndexPath *indexPath = [self.collectionView indexPathForCell:sender];
LocationImage *image = self.savedItems[indexPath.row];
destViewController.captionString = image.caption;
}
}
The cell is probably not responding to touches because you haven't set the image view's userInteractionEnabled property to YES (it's NO by default).
You can't use an unwind segue to go forward; they're for going back to a previous controller, so your preference to use an unwind segue doesn't make sense. Do you mean for the unwind segue to be used for going back from the detail VC? It's not clear where you want this custom button. You already have the segue connected from the cell, so you don't need a button to invoke the segue.
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.
I created a segue from the table view cell (in a master view controller) to a view controller and gave the segue the name "ShowDetail". In prepareForSegue in the master view controller, I setup this code, however if I touch the table view cell in the master list, nothing happens, not even the first log statement gets triggered. when I right click the table view cell in the master view controller, it shows that there's a segue wired up.
Is there a method that needs to be implemented in the master view controller to make the cell response to a touch? or is there another explanation why this might be happening?
-prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
NSLog(#"prepare for segue");
if ([[segue identifier] isEqualToString:#"ShowDetail"]){
NSLog(#"in segue to display edit");
DisplayEditViewController *devc = (DisplayEditViewController *)[segue destinationViewController];
// devc.delegate = self;
NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
Event *selectedJoke = (Event *)[self.fetchedResultsController objectAtIndexPath:indexPath];
devc.currentJoke = selectedJoke;
devc.mood = selectedJoke.mood;
devc.delegate = self;
devc.mnemonicField = selectedJoke.mnemonic;
devc.jokeField = selectedJoke.joke;
}
Update 2
here's a compressed version of the project. As you see, my project lets me add new entries but not display them in the DisplayEditViewController https://dl.dropboxusercontent.com/u/10328969/preppyspeech.zip
Update 3
Even when I implement didSelectRowAtIndexPath in the masterviewcontroller, it (didSelectRowAtIndexPath) is not getting called when I click on the cell. See updated project here https://dl.dropboxusercontent.com/u/10328969/preppyspeech2.zip
I have seen you Project, there is simple mistake, the Selection type for UITableView in MasterViewController is set to No Selection, so didSelect method for UITableView doesn't work, change it from image below
And it works.
Cheers.
I have a Master-Detail application.When the user selects a row in the MasterTable, I want to open another Table (not the DetailViewController). It should paper besides the MasterViewController, similar to the Facebook app on iPad.
I have a Custom segue from the MasterViewController to this table (DocumentViewController of type UITableViewController). This DocumentViewController is 'Embedded' in a navigation controller.
In short, the items on my storyboard look like this:
navigationController->MasterViewController->navigationController->DocumentViewController.
The segue is from MasterViewController to navigationController.
Do I have to perform the segue in "didSelectRowAtIndexPath"? Or do I have to use "performSegueWithIdentifier" in didSelectRowAtIndexPath?
If I understand your question correctly, the segue should be from MasterViewController to DocumentViewController. Make sure to give it a unique identifier, and then reference what you want to do in the prepareForSegue in your MasterViewController.
Example:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([[segue identifier] isEqualToString:#"showList"]) {
// gets indexPath for the currently selected row in my UITableView
NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
// pull back some useful data from Core Data according to what was selected in my UITableView.
NSManagedObject *object = [[self fetchedResultsController] objectAtIndexPath:indexPath];
// listDataItem is a property of the controller (in this case a UITableViewController)
[[segue destinationViewController] setListDataItem:object];
}
}