iOS - Push Segue not working even with NavController - ios

I'm trying to set up a basic "Newsfeed" function for an iOS app, with headlines in a TableViewController segueing into a simple ViewController to display the text of the selected story. I'm using Storyboards to set up the segues, and I can't get it to work...
What I've Done - I started by CTRL+Dragging from the Cell of the TableView onto the secondary ViewController and choosing "Selection Segue - Push." Then I clicked on the segue and gave it the identifier "newsArticleSegue," and I embedded the TableView in a Navigation Controller. I've got the TableView data source hooked up to a plist file as well, although I don't think that would have any effect on the segue, right?
All that happens when I run the app and click on a row of the TableView is that it gets highlighted blue. Clearly the segue isn't working, but the tutorials I've found only list those steps, as though that's all that's needed...
Can anyone tell me what I am missing? And thank you in advance!

When you create the segue with IB, you can drag from the view controller (which you did) or from the table view cell, which will call the segue if the table view cell is selected.

Related

Segue misunderstanding

I am little confused with the way that segue is working in my app.
I have TabBarController and my ViewController inside it is embedded in NavigationController.
I added identifier to segue "mySegue". So when i perform some action inside my ViewController I run
performSegue(withIdentifier: "mySegue", sender: self)
So segue is performed but I have some things that I don't understand.
View is presented without tab bar and navigation bar. Why? I thought that they should be visible by default.
I want segue to be animated - so view will be presented from right to left and also I will be able to unwind it (simply go back by swiping). But swipe back is not working and view is presented from bottom to top. Why is it?
You should set the segue's type to Push - that way the navigagtion controller will issue the hierarchy and it will actually get pushed to its stack, hence the name.
If you want your segue to transits horizontally, you need to use (Show e.g push) for the segue, like this. It has swipe back by default
As it was not the first time when I meet this problem - I need to point where the problem was. Maybe it will help others when it seems that everything in segue is made right way but it is not working the way it should.
In my case - it was because segue was created in interface builder by dragging not from the ViewController's yellow circle to second ViewController. Segue was created from one of subviews or even TableView / TableViewCell inside ViewController. So in that case it wasn't creating segue in NavigationController.

iOS TableViewController push segue to another TableViewController causes strange graphical glitch

With Swift, I'm trying to push segue from one TableViewController to another when I'm selecting a table view cell from the first, however. This occurs.
http://imgur.com/a/HK5Ew
Is there any reason for it? Storyboard in the album too

How to perform segue between UITabBars?

i have my application with 2 UITabBars - on the first mapview, on the second tableview. So what i want is to perform segue by tapping on the tableview cell and go to map(with some data). My problem is to make some realisation for automatic switching(or at least manual) between selected indexes tabbars.
Now if tap on the cell i will have TWO tabbars with TWO maps
I think you're reinstantiating the whole view by performing a segue. Look at this other issue: How can I segue to the second tab of a tab bar controller from the first tab? You probably can fix the issue by performing a standard selector that changes the selectedViewController property of the tabBar (probably passing more info), instead of a segue.

Adding TableViews to TabBarView & how to customise prototype cell

Im building my iphone application and this is how my storyboard looks right now.
First question: Adding another table view
My first two tab bar items are going to contain table views. Now as you can see i have my first table view connected and all, how would i do to get the empty view under Navigation Controller to be a a Table View. Would i need to add another Navigation controller? or how does it work cause i have never worked with tabbars/tableviews before.
Second question: Customize prototype cell
My first Table View can show the data that i inputed as you will see in the following picture. The first picture is how its currently being shown. How can i make a custom prototype cell that would look like the second picture?
Please not that the cells will be very much alike each other in both of my table views. I will have an if statement where i will check a specific thing and if its true it will hide for example the image but all the other things would be the same so would i make a class for the cells?
For better solving your questions, You must first understand the purpose of Navigation Controller. Navigation Controller is there for you to push and pop between controllers, which is convenient when you have levels of data. It manages a stack of controllers. You don't always need a navigation controller to work with tableview. However, it's a common practice to put Navigation controller and TableView (with view controller or solely UITableViewController) together for easy showing levels of data.
Basically, there are two ways to add a TableView. You can directly drag a table view onto your empty view controller or delete the empty VC, then drag a UITableViewController. Most importantly, select the whole VC and go to Editor (at the top) choose embed in a Navigation Controller.
Link about navigation controller from Apple's document
Since you use storyboard, you can directly customize your tableViewcell in storyboard. You already have a prototype cell. You can now directly drag UIImage or Label on that. Most importantly, create a class subclassing UITableViewCell and connect objects in your tableViewCell as an IBOutlet so that you can control it. If you feel plain text explanation is not enough, I find a tutorial for you.
You could refer to the link section Prototype Cells.
1) Yes you will need a 2nd navigation controller for each tab.
Delete the UIViewController.
Drag a UITableViewController to the storyboard.
Embed the UITableViewController in a NavigationController.
Set a segue from the tab bar button to the new NavigationController.
2)
To fully set up the prototype cell you showed you will need to create a new class which subclasses UITableViewCell and then set IBOutlets for all the labels etc.

UINavigationController in Container View: push segue on table view cell does nothing

I have a container view which embeds a navigation controller (UINavigationController) with a root view that is a UITableViewController. One of the prototype cell has a push segue on selection to another UITableViewController. This is all via the storyboard in XCode 5. No actual code.
Unfortunately nothing happens when the cell is selected.
What am I missing?
Thanks
I tried before with that structure and it should work well. Here is an example screenshot of the full storyboard:
Found the solution. In my controller showing that custom animated controller, I needed to use addChildViewController.

Resources