Modal view before UITabBarController - objective-c

Im trying to present a modal view controller from subclass of UITabBarController. I present it from viewDidLayoutSubviews method. Everything works fine on iOS 7 but in iOS 8 when app stars i still breafly see TabBarControllers first tab.
TabBarController is set as initial view controller in storyboard.
Is this even a good way to present it or there is something for iOS 8 that i dont know?

I don't have the rep to post a comment, so I'll seek clarification and provide guidance through this answer.
Is the intention that the modally presented view controller will be the first thing people see when they launch the app? And then I suppose it gets dismissed, and behind it will be the tabbar controller? How is your storyboard currently set up for the modal view controller if the tabbar is set to be the initial view controller?
One place to start could be to move to code to viewWillLoad or viewDidLoad rather than viewDidLayoutSubviews. I could also suggest to just make the modal VC the initial view controller

Related

iOS 6 view controller layout doesn't update after orientation change when covered by a modal view controller

I have an iPad app which works great for iOS versions earlier than 6.
My root view controller displays a list, and when you click on any item in the list, the root view controller presents a modal view controller to show the item's details.
The problem is, my root view controller has different layouts in landscape and portrait, when there is no modal view controller present, it updates the layout no problem at all when the orientation changes, but when covered by modal view controller, it doesn't update, and this only happens on iOS 6. So when you click on an item, then the modal view controller comes up covering the entire screen, then you rotate the device, and then dismiss the modal view controller, the root view controller is still in old orientation layout, which is really annoying.
I am well aware of the change that in iOS 6 shouldAutorotateToInterfaceOrientation is deprecated and any view controllers covered by a fullscreen modal view controller won't receive rotation events like they did in iOS earlier than 6. I did what was suggested in this thread: iOS 6 Rotation issue - No rotation from Presented Modal View Controller, which is manually pass rotation events from the modal view controller to the view controller behind it, but the view controller behind it still doesn't update its layout. Any solutions?
Move all your rotation logic to viewDidLayoutSubviews. It's that simple, you will get the same functionality as before. What will happen is, after you dismiss the modal view controller, the presenting view will be layout, and you can then switch to the appropriate layout for the current orientation.

UIKit messages deallocated object during segue on iOS 6

After upgrading xcode and compiling my app using iOS 6 SDK I got many crashes among the app. From what I was able to track down it looks like UIKit messages deallocated view controller during modal segue instead of the newly created one. Here's how it looks:
I have a Tabbar Controller which displays a Navigation Controller. Another view controller that is being presented by the Navigation Controller displays a Modal View Controller.
TabbarController --> NavigationController --> ViewController (presenting) --
| shows using modal segue |
--> ViewController (presented)
Steps to cause the crash:
Access the View Controller (presenting) in hierarchy shown above. It is not root view cntrl but higher.
Trigger the segue to the modal view controller.
Pick a tab from the tab bar (whichever) and go back to the same View Controller (presenting). Picking a tab calls popToRoot on the Navigation Controller.
Again trigger the modal segue to the View Controller (presented)
Crash: Zombie object - View Controller (presented) - got messaged
Why?
It looks like on previous iOS when popToRoot was called and View Controller (presenting) was being cleaned up also the modal view was destroyed. So when it was accessed again it was recreated and presented.
On iOS 6 from what Allocations Instrumentation shows the modal view is destroyed together with
View Controller (presenting). But when it's being accessed for some reason UIKit creates a new modav view controller but then messages the old one that is not existent anymore. Doesn't make sense.
One other thing that makes me wonder is that on iOS 5 Allocations Instrumentation tool never shows me the View Controller (presented) with retain count = 0 but iOS 6 does (afterwards it makes it -1).
I know this is probably very difficult question to help me with but maybe someone was already tackling problems with iOS 6 and such segues?
From Allocations Instrumentation tool I can tell that many things got changed in the implementation of segues on iOS 6.
I've end up implementing custom segues for presenting those modal views. Seems like a quite good idea here.
Maybe one is not supposed to display a modal view inside tab bar view?

Dismiss custom modal view controller

I'm developing an iPad app where I've created a custom segue to present my view controller with a custom animation. It's now working (almost) fine and in the end it looks like a form modal view controller, exactly how I wanted it to look.
Now I need to create a custom animation for dismissing the modal view controller that matches the first animation.
What is the best way to do it? I have my custom animation inside my custom segue and I think the reverse animation should be there also. But I also think the segue is not the place to have it.
How'd you guys do it?
Thanks
Unfortunately you can't use the segue to perform the dismiss of your modal ViewController its jut one way (will change in ios6). just perform your custom dismiss-animation and call dismissModalViewControllerAnimated:NO on the parentViewController in the finished block of the animation.

add or present view before launching first tab view controller

I am making an iPhone app in which I have used both, the navigation as well as the tabbar controller. Now after splash screen I want to show a UIView before showing the first view controller of the tab bar.
Currently I have added one subview on first tabBar controller. But this view gets messed up with the first tabBar controller's view.
Can anyone tell me that is it possible to add or present a UIView before launching the tabBar controller? If anyone has an idea please do let me know.
Use the storyboard. Make your additional view the first scene. Add a segue to the tab view. If you want an automatic transition, trigger the segue by a timer.

How do IOS know which viewController is being viewed and hence need viewWillAppear to be called

How does iOs know?
Does each view has a pointer to it's controller?
What happened?
When we pop a viewController from navigation, does the navigationController arrange which view should be called?
For example:
If I added:
[[BNUtilitiesQuick window] addSubview:[BNUtilitiesQuick searchController].view];
viewWillAppear will be called.
ios does know which viewControler viewwillappear should be called even under cases in the question. There is no way I can think of how they know that without a pointer from view to viewcontroller.
However, window doesn't know the viewController. I am passing the view outlet of the controller not the controller. How can iOs 5 knows that it has to call [[BNUtilitiesQuick searchController] viewWillAppear:YES]
Navigation Controller maintains a stack of view controllers.
Once a view controller is popped, it is removed from the stack, and now the view controller exactly below this is the first view controller.This is how it works.
You can check documentation for more details - http://developer.apple.com/library/ios/#featuredarticles/ViewControllerPGforiPhoneOS/Introduction/Introduction.html#//apple_ref/doc/uid/TP40007457
http://developer.apple.com/library/ios/#documentation/WindowsViews/Conceptual/ViewControllerCatalog/Chapters/NavigationControllers.html#//apple_ref/doc/uid/TP40011313-CH2