Segue not working on tableView - ios

Okay, I got this strange situation.
I have multiple tableViews in my project, but only on one tableView I can click on an item and perform an action (go to next segue).
On the other tableViews I can click what I want but nothing happens.
I removed the one that was working and made the link again, and it was still working. What am I missing?

I'd like to suggest to you to use the delegate method to handle item selection:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
// Here you can do something with, e.g. push a view controller:
id vc = [self.storyboard instantiateViewControllerWithIdentifier:#"myVC"];
[self.navigationController pushViewController:vc animated:YES];
}
In most cases it is more comfortable to implement and maintain table views with delegates instead of using segues.

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.

How to connect two view controller to one view controller using Storyboard?

I'm trying to connect two view controller into a one controller. As you can see below picture, when "plus" item is tapped the screen came and it works well. However, the other segue doesn't work properly. With my first tapping to any row, it doesn't take me to the view but after first tapping it starts taking me to the view as I wanted. I couldn't figure out why it doesn't take me to when I firstly tap any row. Here is the didSelectRowAtIndexPath code:
- (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath{
DovizDetailViewController *detail = [self.storyboard instantiateViewControllerWithIdentifier:#"detail"];
[self.navigationController pushViewController:detail animated:YES];
}
Below is my storyboard. The problem is about with the above view and it's segue.
Hope you can help me.
Thanks!
Change didDeselectRowAtIndexPath to didSelectRowAtIndexPath

Table view cell to another view controller

I'm creating a small app with StoryBoard, that currently consist of a Navigation Controller, Table View Controller and a regular view controller. I have an array of objects that is connected to the table view, and now I want to select one of the objects and get the regular view controller on the screen. So, in StoryBoard I CTRL-drag from the prototype to the view controller in order to create a segue (push). Now, I want it to work, but literally nothing happens.
What am I doing wrong? Shouldn't this work directly or am I missing to set some options? I really want this to work with the StoryBoard but I tested to give the segue an identifier and implement the below metod, but that didn't work either.
-(void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath {
[self performSegueWithIdentifier:#"showInfo" sender:self];
}
for navigating from UITableViewCell, You need to write your "code for navigation" in UITABLEVIEWDELEGATE method,
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
// your code for navigation.
}
First, you are using the method tableView:didDeselectRowAtIndexPath:, where it should be tableView:didSelectRowAtIndexPath:. Don't worry, that's something I keep doing from time to time.
Then, make sure your segue's identifier is "showInfo" in your storyboard and you are good to go.

Pushing new view controller from UITableView on a Tab Bar application

I have an app with two bar in it.
one of the tab .xib includes UITableView, when the user select one of the cells, I want to show another UIViewcontroller (.xib file) that includes information about the his selection.
now, I've tried this
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
*)indexPath {
NextViewController *nextController = [[NextViewController alloc] initWithNibName:#"NextView" bundle:nil];
[self.navigationController pushViewController:nextController animated:YES]; [nextController changeProductText:[arryData objectAtIndex:indexPath.row]];
}
and nothing happened, the console is showing no errors at all.
what seems to be the problem?
thanks!
Nothing happened, because your self.navigationController returns nil.
For proper usage of Navigation controller, you must have at least one. For the case of TabBar application, for each tab you must associate not the UIViewController subclass, but UIViewController subclass nested in UINavigationController. That's easily done both in the .xib or in code. Just google for some tutorials.

Split View like Settings

I have created a basic Split View and instead of loading a UIView on the right hand side, I have loaded a UITableView. The UITableView is made up of UITableViewCell's and what I want to do is when I click on the Cell, it loads up another UITableView for selection much like that in the iPad settings. However I cannot the UITableView to load after selection.
Any ideas how to achieve this? I've seen similiar questions and had a look at the apple site with uitableviews but haven't been able to solve the issue as they're geared towards iphone which doesn't have the split view.
On the didSelectRowAtIndexPath i've loaded it like so which other apps have done but to no avail.
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[tableView deselectRowAtIndexPath:indexPath animated:YES];
if(indexPath.row == 0)
{
LevelTwoController *leveltwoController = [[LevelTwoController alloc] initWithNibName:#"LevelTwoTableView" bundle:nil];
[self.navigationController pushViewController:leveltwoController animated:YES];
[leveltwoController release];
}
}
Another thing also is my leveltwoController is a UITableViewController and I just keep getting this import error literal-pointer#_OBJC#_cls_refs.
Your main view that has the TableViewController needs to be controlled by a UINavigationController, and then you could push the subsequent views onto the view stack. My guess is your current implementation is having self.navigationController be nil so nothing is happening.
If you take a look at some of the basic xcode templates that use uinavigationcontroller's you should be able to figure out the proper path.

Resources