Unwind segue results in black screen? UITabBarController with embedded VCs and segues - swift

I have the following hierarchy for my app:
UITabBarController, first tab is a BrowseVC (another UIViewController). BrowseVC has a SegmentedControl, each of which will show a version of the PersonVC (another VC with a UICollectionView in the ContentView). They are each loaded with a lazy instantiation like this article. Tapping a cell in the PersonVC will show PersonDetailsVC via a modal segue.
I'm attempting to put a "Back" button on the PersonDetailsVC to get back to the PeopleVC collection view. I thought I'd have to put the unwind segue in the UITabBarController, however, while it is called just fine (a print statement shows it "works"), the view is black.
Using the Xcode view debugger, the PeopleVC is in the hierarchy on the left, but I've no idea where it is physically.
For this configuration, which VC should the unwind be located in? I've tried putting in the BrowseVC and the PeopleVC but it would seem logical that the TabBarController would need to reload all of the content? Is there a best practice for this scenario? I can't imagine this is very unique at all. What gotcha(s) might I be missing?
TIA!

Apparently it is the modal presentation that is killing the unwind capability. Other presentation methods work fine. Disappointing.

Related

Changing storyboard segue `kind` between "Show" and "ShowDetail": why does the change not take effect when running the simulator?

First of all, note that this is not a question about "how to finish my app?" or "why is my app not working?", but covers an issue that I happened to stumble upon while playing around with a simple app, and that I cannot for the world of me explain. Perhaps someone here at SO can explain why this apparent issue happens.
For the sake of learning, I've been playing around with a simple app consisting of an UITableViewController embedded in an Navigation Controller. From the table view cells (subclass of UITableViewCell) one can navigate to a simple UIViewController. See the storyboard overview of the app below, and note that this shows the state of the app (development) just prior to setting the segue transition between the table view cells to the view controller.
Now, in my app, I tested two different type of segues between the table view cells and the view controller, namely
A "Show" segue from the cells to the view controller, as can be seen in this gif.
A "ShowDetail" segue from the cells to the view controller, as can be seen in this gif.
Based on the on the Apple documentation on storyboard segues, I expect, while running the app, the following behavior in the view controller part of my app:
With the "Show" segue, the view controller scene will be presented with a navigation controller bar, containing a default "Back" button on the top left corner of the scene (within the bar). Let's denote this as behaviour (A) from here on, and see this image for visualisation of it.
With the "ShowDetail" segue, no navigation bar will be present. We'll denote this as behaviour (B) from here on, and see this image for visualisation of it.
Both cases 1. and 2. above yield their expected results, behaviour (A) and (B), respectively.
Now to the part that I cannot explain:
I set my segue to "Show", and thereafter change---in the attributes inspector---the segue into kind "ShowDetail", as can be seen in this gif. After the change, everything looks good in the storyboard (no navigation controller bar in the view controller), but when running the app, I still get behaviour (A), i.e., the behaviour expected for the "Show" segue.
If I do the vice versa; create a "ShowDetail" segue and change into "Show" via the attributes inspector (as can be seen in this gif), I get the same unexpected (for me) behaviour, namely behaviour (B), i.e., the behaviour expected for the "ShowDetail" segue (no navigation controller bar)
I can also track the same unexpected behaviour by logging the the following boolean:
// In the ViewController code (ViewController.swift)
let presentingViewIsNavigationController =
presentingViewController is UINavigationController
Situation 1. above (using "Show" segue and not changing it) yields, as expected, false (presenting view here is the UITableViewController, and both this and the UIViewController is wrapped in the navigation controller).
Situation 2. above yields, as expected, true (navigation controller is the presenting view of the UIViewController).
Situation 3. above yields, unexpectedly, false.
Situation 4. above yields, unexpectedly, true.
Question: Why does the change of segue kind "Show" to/from "ShowDetail"---performed in the attributes inspector---seemingly not take effect when running app in the simulator?
I'm running Xcode 7.2, and iOS 9.2 in the simulator (simulating an iPhone 6s plus).
One problem with segues that I found while testing is that the action attribute doesn't change when you change the segue kind:
<segue destination="YYV-02-abX" kind="show" identifier="segueshow" id="X7i-33-rvh"/>
<segue destination="YYV-02-abX" kind="showDetail" identifier="segueshowdetails" id="crf-TU-94x"/>
<segue destination="YYV-02-abX" kind="showDetail" identifier="segueshowtoshowdetails" action="showViewController:sender:" id="w2L-45-p7H"/>
<segue destination="YYV-02-abX" kind="show" identifier="segueshowdetailstoshow" action="showDetailViewController:sender:" id="7Z4-mJ-Pbh"/>
So this might be a bug on the Apple side.

Segues where a view replaces another

I'm planning a game app where a series of views are presented, one after the other, sequentially, in a loop.
I'm having a hard time figuring out the segue I should use for this (using the storyboard). It seems to me, that using the 'show' segue will result in a stack of views. In my app, you never go back from where you came, so does that mean that I could end up with dozens of views, one on top of each other?
Is there a way so that once you go into a segue, one view replaces the previous view?
Unfortunately you are not going to be able to do this with Storyboard segues as the "Replace" segue is only for SplitViewController (which sounds like wouldn't be right for what you are trying to do). Instead handle transitions through code. Have a base navigation controller and keep setting the new view controllers as the navigation controller's root view controller

view controllers using storyboard

i am trying to switch between two view controllers using storyboard. I create a modal seague by control-dragging (on buttons) from 1st view controller to 2nd, and then from the 2nd to the first.
So whenever I click on a button in 1st VC, it takes me to the 2nd VC. This time when i click the button on second VC, does it take me back to the original instance of the 1st VC or it creates a new instance?
If it takes me to the same instance, and user had written some data in some textfields, is there anyway to retain that on screen? (I might want to save them in some variables, and since the program will return back to the same instancem i'll be able to get the variables back)
If it doesn't take me to the same instance, is there any method to do so?
I tried making an instance of 2nd VC and using self.navigarionController push...(instance) but this doesn't swtich the controller.
If i do this pushing using the storyboard, and i do pop in my 2nd VC, it doesn't get popped either.
(and i would also couldn't understand the difference between push,modal and custom seagues)
Create the modal segue from VC1's button to VC2, but not the reverse one. When the VC2's button is tapped, call dismissViewControllerAnimated:completion: to return to where you were.
If you used a push segue instead, you would call popViewControllerAnimated: to go back but that only works if you have your view controllers managed by a UINavigationController.
You can think of push as a way of stepping through a sequence of related scenes while modal is something that's a bit out of the normal flow of the application. (That's not a firm rule but it's a starting point for deciding which way to go.) For 'custom', you write the segue code, so you decide what happens.

iOS5 - how to use storyboard to transit from UITableViewController to another ViewController

Using Storyboard I want to transition from UITableViewController to another ViewController on the click of Detail Disclosure button. I created a proper segue, but the transition does not happen when I run the application. Creating a segue from UIButton to a ViewController works properly. I tried embedding Navigation Controller in UITableViewController, it did not help.
Look forward to somebody helping me with this, as I have already spent four days on it.
Thanks!
Here's the most complete example I have found. Most have fallen short by not providing an example of how to go from the list of records to the detail of the selected records.
http://developer.apple.com/library/ios/#samplecode/SimpleDrillDown/Introduction/Intro.html#//apple_ref/doc/uid/DTS40007416-Intro-DontLinkElementID_2
and here's the link to part 2 of the above tutorial:
http://www.raywenderlich.com/5191/beginning-storyboards-in-ios-5-part-2
It should work without any code on your side
Ctrl click the prototype cell (table cell) and drag it to connect with the detail view. This will pop up a segue window. I chose Push since I have a navigation controller - but you can use Modal as well.
Note the segue name should show "Segue from UITableViewCell to ).
I've put in the disclosure icon on the Table cell as well.

Combining UITabBarController with UINavigationContoller

I am sure this is very simple, yet I am stuck...
I have created an application and added UITabViewController (dragged in from the library in Interface Builder. My application has 3 different views, clicking on appropriate tab brings the different view. So far so good.
I want to convert one of the views to be a UINavigationController: basically a table with the option to delete rows (so UINavigationController would need to have a button "Edit" on top).
I saw many samples which would do either 1 or 2, but not both.
How would I combine it, keeping in mind that I have used provided UITabViewController and did not added UITabBar directly to the view.
Thanks
If you are using Interface Builder, you should be able to just drag and drop a navigation controller into your tab bar controller as a child controller. The next tab bar item should be generated for it automatically from that.
You can also do this programatically by just creating however many UINavigationControllers you need in an array and assigning that to the uitabbarcontroller appropriately.
I actually don't like this method of combining the UINavigationController and UITabBarController since the tab bar controller must always be visible, which can be really confusing sometimes.
Instead, I recommend you make your own custom UITabBarController (Tab bar controller inside a navigation controller, or sharing a navigation root view) which you add to the navigation controller. I personally don't know why Apple didn't do this; hopefully this is the standard way in 4.0 :)