Receiver () has no segue with identifier 'secondViewControllerSegue` - ios

I have a custom tableview cell in xib file. I am using this custom cell in my FirstViewController. I want to show SecondViewController on didSelectRowAtIndexPath of first viewController.
And I am performing segue in didSelectRowAtIndexPath like
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[self performSegueWithIdentifier:#"secondViewControllerSegue" sender:indexPath];
}
I am getting error saying -
'Receiver () has no segue with identifier 'secondViewControllerSegue''
What am I missing here?

Go to your storyboard and Ctrl+Drag from the first view controller (the yellow icon of the first view controller) to the second to create a segue. Then on the left panel go to attributes inspector tab and set an identifier for your segue. Then just set the same identifier in your performSegue method.

You have to connect a segue from firstViewcontroller to secondviewcontroller with the name you are using for segue.
And stroyboard id is not for segue it is for identifying controller in the the storyboard.
You have to create segue between you first and second view controller the rest of you code is fine.

Related

TableView cell is not pushing to next view controller

I created the single view application using storyboard.
In storyboard file, i have three view controller
1-navigation controller 2-Recipe Book View Controller 3-View
Controller
Prototype cell of the table view of Recipe Book View Controller is connected through push segue to View Controller.Is the problem Recipe Book View Controller does not navigate to View Controller?
here is the sample of project for download.
https://drive.google.com/open?id=0B5pNDpbvZ8SnLTd1R3NBTE1ReEk
I just Check your project.
Do following steps:-
In Main.storyboard, click on Push segue to ViewController and add name of identifier
Go to ViewController.m and paste below code
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[self performSegueWithIdentifier:#"yourSegueName" sender:self];
}
Following mistakes are found in your project.
There is no class for Third VC.
PrepareForSegue not implemented.
You wanted to push VC on TableViewCell selection but there you does not implemented didSelect tableview delegate.
Select the segue connecting RecipeBookViewController to ViewController , Then give that segue an identifier, i.e. "ViewControllerSegue".
Implement the delegate method of table view and call the performSegueWithIdentifier method :
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[self performSegueWithIdentifier:#"ViewControllerSegue" sender:tableView];
}
Based on your Source code you have to add some code & classes in your project to achieve your requirement.
1st You have to add RecipeViewController to control your Recipe List and Tableview both.
2nd as You have created this RecipeViewController you need to assign this class to respective ViewController in your storyboard.
3rd Assign Segue from PrototypeCell to ViewController where you need to push.
Hope you can understand whats wrong in your Code.

Move from UITableviewcell to a ViewController and back using storyboard

I have a viewcontroller with multiple tableviewcells in it. I want move from one of the tableviewcell to another viewcontroller using storyboard. I have a navigation controller for viewcontroller. I didn't really find a way to solve this.
You should implement didSelectRowAtIndexPath delegate, then some logic for move to another view controller.
#interface ViewController()<UITableViewDelegate>
...
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
AnotherViewControllerClass *vc = [[UIStoryboard storyboardWithName:#"StoryboardNameOfAnotherViewController" bundle:nil] instantiateViewControllerWithIdentifier:#"AnotherViewControllerIdentifier"];
[self.navigationController pushViewController:vc animated:YES];
}
if you want to do with storyBoard then you can use Segue to jump from one tableview cell to another ViewController what you have to do is
1). right click and drag from your table view cell to your desired view Controller and then release it you would see a pop up select "show"
2). click the segue and go to identity inspector and name the segue identifier as you wish
3).then you have to just write a method prepareFor segue methodand in that write if statement like this
if (segue.identifier == "your identifier Name")
{
//`enter code here`write your logic of pushing the viewcontroller
}
the above code for if is in swift and you can repeat the steps for your all multiple tableviewcell with diffrent identifier name
if not using storyboard then use this method
if (indexpath.row == 0)
{
//use the push viewcontroller code here
}
for each index path you can check and push diffrent viewcontrollers
Try this..
Open Storyboard and select your initial view controller
Select editor from top bar menu in your Xcode
Select Embed in and choose UINavigationController
And run your code again...

tableview in normal view controller

I am doing the project which need to use the storyboard to rewrite the old project. I got some problems when I doing it use the storyboard. I use the normal view controller instead of tableview controller, because there are some buttons and labels in this view controller. The problem is I don't know how to link between this view controller and the detail view controller when users select the cell from the table view.
simply drag the tableview to a normal VC.
ctrl+drag from your table to the orange circle below to connect as delegate/datasource.
make your VC to implement uitableview delegate and datasource protocols (#interface MyVC : UIViewController <UITableViewDataSource, UITableViewDelegate>).
write the mandatory protocol methods:
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{}
Select a cell in the Table View. And make a segue to the DetailViewController by ctrl clicking on the Table Cell and dragging to the DetailViewController in the Storyboard.
Then select a segue type based on the type of transition you want: modal, or push (if these view controllers are embedded in a navigation controller, etc.)
Probably you should use following code:
[self.navigationController pushViewController:[YourNewViewControllerClass new] animated:YES];

what is the correct approach to push or segue a new view from only one cell of a dynamic tableview

IOS 6 , XCode 4.6.2 using storyboards
Heres my problem. I have a tableview with 7 cells using dynamic prototype. I would like to segue from the third cell to another tableview (which is going to allow the user to select a country and pass that country back.)
Is it possible to set this up so only that one cell triggers the segue ?
If its not, then I presume I would need to use the didSelectRowAtIndexPAth method - but if i haven't drawn a seque in the storyboard i cant call performSegueWithIdentifier because there is no identifier- and no segue
Any ideas what should do ?
Cheers
Simon
Don't draw your segue from the cell prototype in the table. Instead draw it from the Files Owner icon below your table view controller to the next table view controller. Give it an identifier and then call
[self performSegueWithIdentifier:#"yourSegueIdentifier" sender:self];
in tableView:didSelectRowAtIndexPath.
If you don't have a segue between view controllers you can use push methods of UINavigationController.
If you already have a segue between the two view controllers you can do this:
-(void)tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if(indexPath.row == yourCellIndex) {
[self performSegueWithIdentifier:#"yourSegueIdentifier" sender:objectThatYouSendOrNill];
}
}
If you are using static cells in your table view controller you can directly link segue from your cell to the destination view controller.
You can design the DetailViewController in storyboard itself. Give a StoryboardID for that view controller. and in didSelectRowAtIndexPath
-(void)tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if(indexPath.row == 3)
{
DetailViewController *viewController=[self.storyboard instantiateViewControllerWithIdentifier:#"DetailViewController"];
[self.navigationController pushViewController:viewController animated:YES];
}
}
Dont forget to give StoryboardId for the DetailViewController as DetailViewController

iOS5: NSInvalidArgumentException, reason: 'Receiver has no segue with identifier

I am trying to segue from one UIViewController (VC1) to a UITableViewController (VC2) and I have tried all the usual suspects. Other posts did not seem to find a solution
In the Storyboard I created a modal segue from VC1 to VC2 and give it the identifier "VC2Segue".
Clicking VC1's connections properties shows a 'Storyboard Segue': modal--VC2.
Clicking VC2's connections properties shows a 'Referencing Story Board Segue': modal--VC1
In VC1 I have a UITableViewDelegate method that responds to cell selections in VC1. This is where I attempt to segue to the details view (VC2):
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[super tableView:tableView didSelectRowAtIndexPath:indexPath];
[self performSegueWithIdentifier:#"VC2Segue" sender:self];
}
However, as soon as performSegueWithIdentifier is called I receive an exception:
'NSInvalidArgumentException', reason: 'Receiver (VC1) has no segue with identifier 'VC2Segue''
In case it is relevant. VC1 inherits from an external proprietary library (Parse.com: PFQueryTableViewController) which appear to instantiate a `UITableView'. Hence the UITableView does not show TableCells on the Storyboard, instead VC1 is a delegate of UITableView, which which is how VC1 (A UIViewController) accesses the above method.
I've tripled checked the connections, cut and pasted the text fields, ensured that the storyboard nibs point to classes VC1 and VC2 respectively, and tired both push and modal. I'm clearly missing something, but this is my first tour of duty with iOS.

Resources