Top cell in UITableView hidden behind UINavigationBar - iphone

I have a UINavigationController controlling a stack of UIViewControllers. When I push a certain UITableViewController onto the stack, I find that the top row of its UITableView is hidden behind the UINavigationBar.
This problem only happens on the iPad, not the iPhone. I am using the same stack on both.
Also it only happens on one of my controller stacks. I push the same UITableViewController subclass on stacks controlled by two other UINavigationControllers, and there is no problem.
One difference in the problem case is that the UITableViewController is pushed from a UIViewController that is displaying the results table generated by a UISearchDisplayController. I don't see why this should matter (and, as I said, on the iPhone it works fine), but maybe it is significant given that a UISearchDisplayController hides the navigation bar when the UISearchBar becomes first responder.
The problem affects both the iPad device and the iPad simulator. I am using a typical UISplitViewController design, with these stacks in the left hand pane. The problem still occurs in the popover when in portrait.

I had the same problem after migrating an iphone app to a universal app. Here is what solved the problem for me. open your MainWindow.xib and dbl-click the window object. If it opens in iphone size you need to upgrade your nib. Select the document window and choose the menu item File > Create iPad Version. Save this nib with the name MainWindow-iPad.xib. Delete you original MainWindow.xib and add this one instead. After doing these steps problem disappeared and works fine for me on both iPad & iPhone.
Cheers, Harry

Related

Integrating xib file to stroyboard under UI scrollView?

As in the screenshot 1, I am trying to design view that is longer then screen size of iPhone.
and in second screenshot I changed the size to freeform which is giving me liberty to create longer view than iPhone's length.
My question is is it a standard way to solve this problem. where as my understanding was that we are not suppose to use xib files anymore after storyboard because every thing was moved to storyboard.
So to solve this this problem Do I have to use view(xib) and make it as subview of UIscroll view.
is that a standard way to solve these kind of problems or do we have something with storyboard equivalent which is more efficient ?
PS: I have been researching this problem from past few days. All related questions over here and web, are adding UIView programmatically to ViewController but not a single example I found where one is designing the UIView in Xcode thru xib file and adding it to UIScroll View. Which is common real world problem. all the app where views are longer or wider than screen size are not done programmatically all together. At least I think they are being designed and them added to the Viewcontroller. Please correct me If I am wrong.
The answer is, as it's always been on iPhone, modal views which come and go as needed. You can temporarily add child view controllers, alert views, 3rd party iphone compatible popover knockoffs....
Of course UIView still exists - so where is the problem? What you probably mean is that you cannot set an UIView in a storyboard, storyboards only contain view controllers. But you can still make a xib file containing an UIView of any size you like, and add that one to your scroll view.

Can I use a single XIB to create full-resolution interfaces for both iPhone and iPad?

I want to load in an UISplitView an iPhone XIB, but it should be resized to full screen of the iPad... How can i do it? I dont want to convert the XIB itself!
I have read all the other solutions, but I do not want a second XIB, I just want to show it on both devices iPhone and iPad in its specific size.
So if I load it on the iPad by using the UISplitView, it should be in the full size, and if I load it on the iPhone, it should only have the iPhone size.
First off, there's no such thing as a UISplitView.
From the documentation:
The UISplitViewController class is a container view controller that manages the presentation of two side-by-side view controllers. You use this class to implement a master-detail interface, in which the left-side view controller presents a list of items and the right-side presents details of the selected item. Split view controllers are for use exclusively on iPad devices. Attempting to create one on other devices results in an exception.
So UISplitViewController is just a container. You just pass a master view controller and a detail view controller to it. The master view will be displayed in a popover controller in portrait orientation.
I think either I misunderstood you or your approach is wrong. The reason why this class is not supported on the iPhone is because it wouldn't make any sense. You can't just "resize the splitview" or whatever, you have to redesign your interface separately for the phone. It's difficult to give you any concrete suggestion without knowing what you're doing. Figure out what are you trying to achieve, have a design, make separate nibs for each device and try to reuse code and views as much as possible.
Matt Gemmell wrote a SplitViewController that you can use as subview for the iPad (http://mattgemmell.com/2010/07/31/mgsplitviewcontroller-for-ipad/). You can check the source if you could use this for iPhone too. I found the source too heavy, I simply created an UITableView that loads other views when selecting a row (sort of a fake splitview).

iOS iPad start landscape, push VC, popVC, view has bad positioning

I start my app in landscape for iPad. A nav controller holds my tableVC I click on a cell we push a new VC onto the stack. That works fine. The problem is, when I press the standard "back" button on the nav controller, my app gets forced into portrait and my tableVC is off of the screen. I am doing no manual positioning of views. This doesn't happen if I start the app in portrait mode.
How do I fix this abnormal behavior?
Notes: There is also a tab bar present in the app if it matters.
Upon further testing, if I load the NavController in portrait (with the first view being the table view) then switch it to landscape, then select the cell, then press back, it works fine. So the problem only happens if i start the app in landscape and never turn it to portrait.
EVERY VC has shouldAutoRotate set to return YES. I have subclassed the tab bar and done the same. I am wondering if this is a bug. Perhaps the problem lies in the fact that I took existing .XIB files and their views that were created for iPhone, then copied and pasted them, then deleted the iPhone specific views and then added iPad views.
If your subclassed TabBar Controller returns yes, and ALL of your VCs return yes for shouldAutoRotate, then the problem lies within your xib files. Though your explanation makes it sound like the VC you are pushing doesn't return yes, you've stated that it does, so it must be the xib files.
In IB, try setting the default orientation of your xib views to landscape, clean - build and run.
That may provide a clue or two.
Maybe you can create a new and simple iPad application with just a tabbarcontroller a navigation controller and 2 viewcontrollers to test if the cause is or is not the recycled iPhone .XIB files.
Also you can Command+Shift+F to search in the whole project for ": UIViewController" to double check that every VC has shouldAutoRotate set to return YES, in case you have third party code in your application that has a subclass of UIViewController on it. (the search will return a list of headers files that inherits from UIViewController).
I had had similar problems with really weird behaviors that were fixed by deleting the .XIB file and made it again.
Good luck finding the problem =)

Universal app design 1 table view that opens different view on cell click depending if on iPad or iPhone

I'm making a universal app and I've run across a situation I'm stumped on. On the iPad I'm using a split view, and I would like to make a UITableViewController that is shared on both the iPad and iPhone. I did that, but now when the user clicks a table cell I need to respond. On the iPhone I will init a new view controller and push it in the UINavigationController stack, but on the iPad I will init a different UIViewController and display it in the detail view pane. I know how to do each of these actions by its self, but how do I write the UITableViewController so that it knows which action to preform depending if its the iPhone or iPad?
Is there a better way to handle this?
Here's what I did in that exact same situation.
The table-view controller had a property called detailViewController. If this property is not nil than I updated that view based on what cell was touched. If that property was nil I must be on the iPhone and inside a UINavigationViewController. I use self.navigationController to push my new iPhone view.

Moving a 'UITabBarController with UINavigationController' iPhone app to 'UITabBarController with UISplitView' on iPad

I have an app where the appDelegate has a UITabBarController. Each of the tabs has a navigation controller which I currently use to push a single detail view onto the stack in each tab. I am hoping to replace my navigation controller on each of the tabs with a splitViewController. I use the Interface builder to provide the UINavigationController for each tab. I am having trouble loading a nib for each tab that has a UISplitViewController in it. I am getting an instance of the UITableViewController class displaying on the screen, but I am not getting the UISplitviewController or the Popover or the detail view etc. These classes are all working in a standalone app, but I am not able to get them into each of the tabs in one app. Although I am currently using the Interface Builder I am open to doing this programmatically. If someone has suggestions, or an example small project of a Tab based app with individual split views in the tabs I would appreciate it very much. (As this is my first question I am not sure how much code or other pictures from IB would be helpful for me to post. If you need further detail please let me know and I would gladly amend this post.)
Apple documentation
"The split view controller’s view should always be installed as the root view of your application window. You should never present a split view inside of a navigation or tab bar interface."
Moving on...
Not only shouldn't you -- if you do so, an error is thrown when you run. It's impossible.