Popover View Does Not Show Subviews - ios

I have an iOS app that was created using storyboards with auto-layout. The View Controllers are in a navigation controller. Several steps down the navigation controller chain I have a button in VC1 that is connected to VC2 via a popover segue. When I tap the button, a popover view appears but is blank. I changed the background color of VC2 to see if the view was actually appearing. It was. No subviews were visible. I have created and recreated VC2. I have changed the sizes of the view, the subviews and the view controller. I have manually and automatically created restraints. I also created a test view controller outside of the navigation view controller. It behaved the same as the view controllers in the navigation controller.
Just to check if I was completely incompetent, I created a new project with a storyboard that had one VC. I placed a button in this VC with a popover segue to a second VC. It worked as desired. When the button was pressed a popover would appear and all subviews of the second VC would be visible. I tried placing the first VC in a navigation controller with no change. It continued to show the popover as it should. I have compared the two projects and I can't find what the problem is.
My question is this: Does anyone out there know of some hidden setting that would cause this behavior? or Any suggestions on what I'm missing here?

Well, after a whole lot of time (and even rewriting my project from scratch) I finally found the solution. Apparently, using size classes messes with popovers. To solve this solution, I turned size classes off completely. My app is iPad only so that worked for me. According to this thread: iOS8 Size-Classes and Popover Views you can also use the Any/Any size class. I was using Regular/Regular size class. I hope this helps someone.

Related

Swift - UINavigationBar is disappearing - Storyboard reference

I'm havig this navigaton bar at the very beginning of my project, I'm hidding it at connection and then displaying it later on.
My sotryboard began to get huge so I've decided to put the parameters views of my app in a second storyboard.
The second storyboard begins with a view (that I'm displaying using "Presentr" library) which has already no access to the navigation bar from the first storyboard.
I think that the storyboard reference is somehow destroying my navigationController.
What am I doing wrong, and what should I do to correct it ?
My issue was because of library "presentr". Somehow when I'm using this library to dsplay a VC (no matter how it's linked into the storyboard), the VC loses the hierarchy with the navigation controller.
Hope it'll help

UINavigationBar missing from UITableView

I'm presenting a UITableView modally to provide access to some application settings. When the modal view (root view controller) appears, it has a navigation bar like I expect. However, when one of the options is selected and the next 'UITableView` is popped to the top of the stack, there's no navigation bar.
Here's what one of the child UITableViews looks like:
As far as I know, the two children views should have navigation bars without me having to do anything because they're embedded in a UINavigationController.
I tried dragging a navigation bar to the views but IB will only let me put them inside the UITableView and if I do that, they do appear, but they also go too high in the view and run into the status bar and I can set any layout constraints on them to fix this.
I've scoured the Apple documentation with no luck and found many thread on SO that very, very old and in objective-C.
Can I make these views work together like I'd expect them to or am I going to have to build the child views from scratch?
UPDATE: I'm still trying to get this to work. I've now tried to create a new view controller from scratch. Here's what the view hierarchy looks like:
And you can see in the Storyboard something's not right:
And when I run this in the simulator, I get a new error:
"[UITableViewController loadView] instantiated view controller with identifier "UIViewController-cDg-wV-aMN" from storyboard "Main", but didn't get a UITableView.' But I created the segue by Ctrl-dragging from the cell in the root VC directly to the Table View.
To sum this all up, here's the flow I'm trying to achieve: UIViewController (initial VC) -> UINavigationController (presented modally from the bottom) -> UITableViewController (presented from right to left and with standard navigation bar).
My segues are all set to Show (e.g. Push)
Any help or suggestions would really be appreciated.
Well, I figured out how to fix the problem I was having after coming across another thread that wasn't about the same problem, but it had some advice that tipped me off.
The problem was caused by me creating the segues from the UITableViewCell on my Settings view controller to each of the child UITableViewControllers.
To fix the problem, I simply created the segues between the Settings UITableViewController and each of the child UITableViewControllers.
Hope this helps somebody else someday.

Shrink view controller while presenting another

I want to modely present a view controller, and during the animation I want to shrink the presenting view controller. I saw a lot of apps doing this effect, its seams that the entire view controller including the navigation bar is shrieked.
I'm not sure how to approach this, and I will really appreciate any help about how to make this kind of effect.
here is an example from the mail app, you can see that when the compose view controller is presented, the other view controller is shrieked behind him:
If this was for iPad I would tell you to simply use an embed segue, or resize your modal container's superview, but since it is for iPhone that makes things trickier. Apple has said that modal presentation for iPhones is always supposed to be the whole screen, so I doubt they did theirs modally. They either made a custom segue type (I'm not sure how to go about doing that), or they simply are using a view and presenting that on the bottom portion of the screen, with a view inside of it to represent the navigation controller.
You can add a different viewController's view to the current view controller then call parentVC addChildViewController: and use it like that. Just use a toolbar instead of a nav bar and it should work fine.
I was looking to do the same and I found this answer by Brian Sachetta that explains how to accomplish it. The link posted in the answer didn't work for me but I found the sample he is talking about here

Xcode segue leads to back screen sometimes

I have two view controllers that are linked to each other via segues. Both segues are modal, and have identifiers. Both view controllers have storyboard IDs and titles. When I go to my second view controller (VC2) I sometimes get a completely black screen (except for, strangely, a UILabel which has its text updated by a NSTimer every second). I have to check/uncheck animated on the segue several times to get it to work again. I have no idea why this is happening. I tried switching the views programmatically, and the problem went away, but I'd prefer to use less code and I have to share data between the segues. Anyone have an idea?
Either try what Calvdeos is saying
Or Use Navigation controller. Push first VC in the navigation controller. Then upon user action, push second VC on top of it. Then when VC2 is done, pop it off the VC stack.
It really depends on what the flow is. If you expand on the logical flow, i can suggest better.
Thanks everyone. Managed to fix it. The UILabel that would show up under the black screen had a bad IBOutlet. I deleted that outlet and fixed it, everything worked fine.

Adding a toolbar to a navigation controller

I am completely new to ios development and I am only interested in developing for ios5.
I have an app with some scenes, they are mostly tableviews. I also use a navigation controller
I however need to add some status text and buttons that are always visible in all scenes and thought that a toolbar added to the navigation controller should do the trick.
so i thought that i should only have to drag out a toolbar in storyboard to the navigation controller, but it does not stick there. I can add it to the bar underneath with first responder and navigation controller but that does not help me (small icons).
I can also not add it to my table view (but if i drag out a plain view I can add it there)
do I have to make my own custom navigation class that the navigate view uses and then programatically add my toolbar?
Had the same question recently. Check Attributes Inspector in your ViewController's properties in storyboard. There you can define a Bottom Bar.
Well, inside the UINavigationController, you should have something... A UIViewController for instance. You can easily add a UIToolBar by dragging the object inside the UIView of the UIViewController. What might being happening is that as the root view you have the UITableView, in that case I think you can't do that. But to better understand, just take a small print screen of your StoryBoard.
If you zoom up to 100% on the storyboard it should drag.

Resources