Second tab is always a black screen - ios

I have a UITabBarController that has 2 items. Each of them points to a different UINavigationController, however both of them point to the same UIViewController. The first item is displayed correctly but the second on is not. What's happening.
No code is necessary for reproducing it.

A view controller can't be in different navigation controllers at the same time. You need two scenes here. This is one reason why I don't like Storyboards.

Related

Keep state of navigation controller and only change view

I have an application with a drop down menu as the titleView of my NavigationController. When a user selects an item of the drop down menu, the entire view should switch contents, however, the NavigationBar should remain the same. The NavigationBar should not have to reload any data and the titleView should remain a drop down menu.
The original view upon opening the app:
The view upon touching the dropdown menu:
I currently see a few ways of going about this:
Set up a UIViewController for each option, perform the segue, and reload the data.
Why this is bad: I will have to set up a segue identifier for each ViewController, meaning if I have 15 options in my drop down menu, I will have 210 segue identifiers laying around. I will also have to reload all of my NavigationBar data.
Why this is good: I will have a clear area to set up each individual view.
Programmatically add and remove UIButtons, UILabels, and UIWhatevers as I need them.
Why this is bad: This will create a lot of code inside just one ViewController and things could get difficult to debug.
Why this is good: The NavigationBar never gets reloaded.
Add a container and embed a unique ViewController for each item as I need it.
Why this is bad: All of my work would still be in the main ViewController and I'd have to manage the logic of the embedded ViewController inside one Controller.
Why this is good: The NavigationBar never gets reloaded.
A completely different method suggested by someone else because I don't know the most efficient way of doing this.
So, in conclusion, what is the most efficient way to maintain state of my NavigationBar when switching my main content in my View?
Option 3 is the best out of the three you listed. Options 1 and 2 will get more and more complicated the more view controllers you want to add. Compare that to UINavigationController, UITabBarController, or UIPageViewController which do not need to be more complicated in order to handle 10 screens vs. 100 screens.
I would suggest creating a custom container view controller (Apple's Reference)
I see 2 immediate approaches to implementing this:
Subclassing UIViewController - this is how Apple's container view controllers are implemented
Subclass UITabBarController - I have done this successfully, subclassing UITabBarController to show a custom tab bar at the top instead of along the bottom.

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.

master controller with buttons needs to load pageviewcontroller. master buttons not accessible after first load

I am new to xcode and IOS (and this board. First post).
I am completely flummoxed by a design problem and unsure how to approach.
I have three buttons, each of which calls a new array of pages that need to navigate horizontally with swipe gestures and have their own buttons.
The three buttons in the parent work exactly like a tab bar except they have to be bigger and higher than a tab bar would be. The called page arrays mostly work like a pageviewcontroller except that the pages need to have a button/indicator below to allow non sequential navigation. The target HAS TO LOAD WITH A SEGUE.
The problem I'm encountering is that using a modal segue to load a pageviewcontroller and prepareForSegue to keep the master/parent view controller visible results in my buttons being inaccessible. I assume its because I cant click thought the child view controller.
Secondly, I don't know if its possible to customize the page indicator dots of a pageviewcontroller so they can look like a bar with graphics.
Here are my specific questions:
Is it possible to load a view controller with a modal segue and still access my buttons? Can the child be resized?
can i customize the buttons/indicators in a pageviewcontroller. Can you point me to some code?
should navigation like this be done with some completely different approach? What about a view controller container?
Here's a diagram (cant post images directly yet)
I've found the answer to my second question: It seems that pageViewController's indicators are not customizable in any way. This rules out pageViewController for what I need.
9 Views in 10 hours. Is this not the best forum for questions like this or is there something wrong with my post?

nested segues app performance

i want to use a tab bar on top of the view controller not in the bottom. after searching, i found out it's against Apple's UI Interface Guidelines and it should always be at the bottom. However, my app has to have also one at the top. Anyway, i was thinking of using nested segues. For example, if we have three view controllers that each has 3 buttons on top that resemble the tab bar items, and i'm positioned on the first VC (hence, the first button is highlighted). When i press on the second button it gets highlighted and segues to the second VC. Then if i press of the first button, i'll be taken back to the first VC. My question here is if i worked using this paradigm, will the VC's be stacked? will the performance of the app decrease? can i achieve this in a better way in case the answer of the previous questions were negative?
try these projects
MHCustomTabBarController
ICViewPager
JCMSegmentPageController
QMBTabs

How to add an ADBannerView together with a UITableView in a UITabbar?

I'm a little bit confused about view-hierarchies when they meet ADBannerViews.
I want to insert iAd-Banners programmatically into an existing app, but I don't know where to start. I did read apples documentation and watched a really good WWDC-video, but I still have difficulties to understand how I can use this informations to bring ads in a propper way into my app.
Here is the architecture of my app:
At the bottom there is the window.
The rootViewController of that window is a UINavigationController.
The first viewController in the navigationControllers stack is a UITabBarController.
This tabBarController holds five simmilar UITableViews.
Tabbing on one of the tableCells of one of this tableViews pushes a new viewcontroller onto the navigationControllers stack.
This new viewController is again a UITabBarController, but this one has just four tabs, and the four Viewcontrollers in this tabBarControllers array are:
two different UITableViewControllers
two different simple UIViewControllers, one with just a single picture, the other with many nested views.
I want to insert an ADBannerView at the bottom of each of this four children of the second tabBarController in the navigationControllers stack. And I am not shure how to to this.
My problem is: I do not understand what will happen when the user tabs onto the ad. I know, that the ad's code will push a new view over my app, but I do not understand how. Will the new view be part of the stack of my navigationController (I don't think so)? Or will the new view be a new subview of one of the tabBarControllers views?
I don't have any proof, but my guess is that when the user taps on the banner, the ADBannerView code will push a new subview onto the view of the root view controller, because it needs to display full screen, on top of everything in your application. The root view controller is typically set in your applicationDidFinishLaunchingWithOptions method.
p.s. off topic a bit but are you sure you want to change the number of tabs? The more conventional UI paradigm is the tabs stay constant at the bottom of the screen. In that case, you have a UITabBarController with several UINavigationControllers under it.

Resources