Storyboards and UISplitViewController not working under iOS 7 - ios7

I have an app that must support iOS 7-9. The views are laid out in storyboard, it's a tab bar controller, with each tab containing a split view controller.
Everything works fine, except with an iPhone running iOS 7. I have the following code to collapse the split view controller to show the detail:
UINavigationController *splitNav = self.navigationController;
UISplitViewController *split = splitNav.splitViewController;
split.delegate = self;
But on the iOS 7 iPhone, split is nil (as there is no split view controller under iPhone on iOS 7) so splitViewController: shouldHideViewController: inOrientation: never gets called and I'm stuck in a weird state.
I tried push the detail controller onto the navigation controller manually, but the view never loads (just get a black screen), although the controller logic executes.
Can I either set that behavior with with storyboard instead of in code or is there some other way to reference the detail of a split view controller that doesn't exist?

Related

Modal view before UITabBarController

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

UISplitViewController not working correct in portrait mode on iPad

I am working on an iOS 8 app that is using a UISplitViewController. I have a custom subclass of UISplitViewController and the app is working fine except for one small issue.
I have a button in my table view in the master that brings up a modal form sheet. The form sheet has a done button that is triggering an unwind segue that is handled in my custom subclass of UISplitViewController. This method gets called in all orientations on the iPhone and in landscape on the iPad but in portrait when the master view is a popup my method does not get called. It is like the split view is no longer in the chain so when iOS is looking for a controller that handles the unwind segue method it doesn't go all the way up to the split view. Has anyone seen this before and have any idea how to handle this situation?

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?

UISearchBar on iPad table view disappearing below navigation controller bar

I'm working on a Universal app, using storyboards, and I've added a UISearchBar and a UISearchDisplayController to one of my table views. I've hooked it all up, and can search fine. The problem is when I push a new view controller onto the navigation stack. On the iPhone, this is fine, but on the iPad, it results in the pushed view controller being offset underneath the navigation bar (I had to manually make the navigation bar reappear so that you could get back).
Then, when you navigate back to the original table view where the search was taking place, the search is still active, but the UISearchBar is now hidden behind the navigation bar, meaning there is no way to dismiss it without deleting the query. It also means that it is not longer usable, since you can't get back in to it.
Probably best illustrated using some screenshots.
Here is how it looks when you first open the tableview:
Then doing the search is fine:
Clicking through to the next screen, we can see the issue:
And then back on the original screen, still doing the search but no search box:
Then, if I delete everything from the search box, and get rid of the overlay, I can see the search box when I scroll the table view up, but can never reach it. I can't get a reliable screen grab of that though.
I've looked everywhere for a solution but haven't been able to find one. I've tried calling [self setNeedsDisplay] and [self setNeedsLayout] in the viewDidAppear method, but that seems to have no effect. It seems to rectify itself if I change the orientation of the device, and I was trying to replicate what it would do in that situation by calling those methods.
The structure of the iPad storyboard is: SplitViewController -> Navigation Controller -> UITabBarController -> UITableViewController (contains UISearchBar etc.f) -> UITableViewController
I submitted this issue to Apple DTS, and they responded:
The structure of the iPad storyboard is: SplitViewController -> Navigation Controller -> UITabBarController -> UITableViewController (contains UISearchBar etc.f) -> UITableViewController
The fact is that your project architecture does not follow our guidelines which are:
From the Combined View Controller Interfaces section of the View Controller Catalog for iOS:
When combining view controllers, however, the order of containment is important; only certain arrangements are valid. The order of containment, from child to parent, is as follows:
Content view controllers, and container view controllers that have flexible bounds (such as the page view controller)
Navigation view controller
Tab bar controller
Split view controller
Basically, you should have a structure as follows:
SplitViewController -> UITabBarController ->Navigation Controller-> UITableViewController (contains UISearchBar etc.f) -> UITableViewController>

How to switch from one view to another in iPhone?

I am a beginner in objective-c. Can anyone please tell me how can I switch from one view to another in an iPhone application.
View Programming Guide for iOS
iPhone View Switching Tuturial
How To Switch Views using Multiple Viewcontrollers (Method 1)
Switching Views with Animation
How to animate View swap on simple View iPhone App?
switch between uiviews with buttons and not uinavigation controllers
Switch between UIViewControllers using UISegmentedControl
There are 3 main controllers that can switch views for you:
UINavigationController
Here you push and pop views in a chain.
There will be a navigation bar on top which lets you navigate back to where you came from.
UITabbarController
Here all the views will be represented by tabs at the bottom of the screen.
You can switch back and forward between them by clicking them in the tabbar.
UIViewController
There is a method in UIViewController wich lets you "present" other viewcontrollers. It's called presentModalViewController:animated:
You will have to do your own navigation back to the parent by using dismissViewControllerAnimated:
You can also do your own switching with variations of addSubView: or view.hidden or similar, but I would recommend those 3 to begin with.