View behind UINavigationBar in UIViewController with two UITableView in iOS7 - iphone

Using iOS7 I have 2 UITableView in UIViewController sharing half of the screen vertically. When the view is loaded the left tableView is displayed correctly starting below the translucent navigationBar and goes behind it when the tableView is scrolled up. But the problem is with the right tableView because it is starting from top of the screen which is behind the translucent navigationBar.
Can anyone help me out on this as I need right tableView below the navigationBar and when I scroll it goes behind it.

The problem is the system does not update the content insets correctly for the table views.
Try this:
- (void)viewDidLayoutSubviews
{
self.tableView2.contentInset = self.tableView1.contentInset;
self.tableView2.scrollIndicatorInsets = self.tableView1.scrollIndicatorInsets;
}

Related

NavigationBar weird extra white space

I'm using a usual view controller with UITableView which is embedded into a navigation controller which is embedded into a tabbar controller:
TabBar Controller
Navigation Controller
UIViewController with TableView
I'm using NavBar with a large title. When I scroll up in a usual way navigation bar with its large title has normal height. But when I touch status bar and tableView scrolls to top, navigation bar gets extra white space between a status bar and its title:
Normal space when scrolling with a finger: https://ibb.co/0BWgB0T
Extra space when touching status bar: https://ibb.co/LxFwDKx
The only thing that helps to avoid that extra space is the following:
edgesForExtendedLayout = UIRectEdge(rawValue: 0)
But it makes tabBar grey, not white as it should be and anyway seems like a quite incorrect solution.
Have anyone faced the same problem?
Ok, suddenly I've found a solution. Yes, it includes this line of code:
edgesForExtendedLayout = UIRectEdge(rawValue: 0)
But also I had to set a tabBar color to preferable and disable its "Translucent" property in Interface Builder.
Hope it'll help someone.

How to set the origin of the root view controller in a UINavigationController?

I've got an app that worked OK in iOS 4 but is having several problems in iOS 5 because of the tab bar related changes. In a couple of cases I have a UINavigationController with no buttons and a UITableView as the root view. The UINavigationBar background header image is fairly tall, and as a result the top row of the table is getting hidden. I need to somehow move the root view controller origin down about 40 pixels.
I've tried setting the nav bar height -- this just hides more of the table as I increase its height.
I've tried setting the origin of the root view controller's view -- this seems to be ignored.
I'm kind of running out of ideas.
Anyone know how to push the origin of the table view down?
Well, after scanning through all the superclass methods about 6 times I finally realized that a UITableViewController has a UITableView which is a subclass of UIScrollView, and UIScrollView has the inset property. Setting the top inset (which is, oddly, in points) provides padding above the start of the table.
The scroll view still wants to display the table scrolled up with the first row hidden behind the header, but doing scrollRectToVisible: fixes that.

Resizing view to display over hidden uitabbar in iPhone

I have an uitabbarcontroller which contains a couple uiViewControllers.
When i show one of those controllers i am hiding the tabbar. This view has a fullscreen uiimageView. The thing is i am seeing a white rectangle over where the tabbar is hidden.
I have tried resizing the views but the white rectangle is still there. Any ideas? Thanks
Fullscreen in the tabbar or for the entire viewport of the device? The rectangle is there because one of your views is not positioned correctly.
Validate that your UITabBarController and/or UIViewController is set to the correct size and the correct position on the screen.

Top margin on UITableViewController

I have a TabBarController, one of the tabs of which contains a sub view which is a navigationController. I am then loading into the navigation controller a view which inherits form UITableViewController.
My problem is thta for some reason the table view starts behing the navigation controller, not the top of the screen but about half way down the navigation bar, hence the top of the first cell in the table view is cut off.
Can anyone suggest how to move the UITableViewController down?
Fix it programmatically:
- (void)viewDidLoad {
UIEdgeInsets inset = UIEdgeInsetsMake(20, 0, 0, 0);
self.tableView.contentInset = inset;
}
This "tucked in behind the Navigation bar" issue is due to iOS 7 using fullscreen layout automatically. See the iOS 7 Transition Guide.
It's a bit devious since it displays as in iOS 6 in the Simulator (layout-wise; ie. not tucked in behind).
Is your navigation bar translucent? Mine was, and setting it to non-translucent fixes it on Iphone iOS 6, iPhone iOS 7, and Simulator 7.0 building with XCode 5. (In my case I set it to translucent for visual appearance.)
You can set the frame of the UITableView to an explicit X,Y position by setting the frame property on the view. Or you can change the same property using interface builder depending on whether you've added the tableview via IB or in code.
eg.
myTable.frame = CGRectMake(0.0, myTable.frame.origin.y + NAV_BAR_HEIGHT, myTable.frame.size.width, myTable.frame.size.height);
This will position the table myTable (which is a pointer to the UITableView) below the navigation bar, you may also need to adjust the height of the table accordingly. The height of the nav bar which I am indicating with a constant is 44.0.
I typically do this type of view adjustment if it has been necessary in the viewWillAppear of the view controller responsible. It's not common that you'll need to make this type of adjustment so it may be something you can fix by changing the way your views are being setup.
Without more details of how your view is setup it's hard to be more specific.

Resizing UITableView on RootController

Is it possible to resize the UITableView on the RootController of a nav based app? When RootViewController.xib is opened in IB, there isn't a view. Just the UITableView. Clicking the inspector and then the little yellow ruler, frame height is grayed out. I'm adding a toolbar programmatically to the RootViewController:
[toolbar setFrame:rectArea];
That works fine but the bottom cell in the tableview is partially hidden because the tableview doesn't know about the toolbar.
The easiest way, is to adjust the contentInset (which is inherited from UIScrollView). Resizing by setting the frame can cause crazy drawing bugs in cells.
For example, if you are trying to resize a tableview for the keyboard, do something like this:
tableView.contentInset = UIEdgeInsetsMake(0.0, 0.0, 216.0, 0.0);
tableView.scrollIndicatorInsets = tableView.contentInset;
Hope that helps someone. This way worked best for me.
Yes, but you need to have a ViewController (not a UITableViewController) as the root controller for the nav, and wrap the actual UITableView in the UIViewControllers view.
You can still have the UIViewController conform to the UITableViewDelgate and Datasource protocols, and use all the same methods you have now in your UITableViewController.
P.S. you'll get more responses if you use the plain "iphone" tag.
You could also just set the Content and Scroller inset of the tableview
I encountered a similar issue when attempting to display the detail controller by itself, see: http://vimeo.com/13054813
The issue is that the SplitView controller applies its own transform to the sub-controllers, taking them out of the orientation detection loop, which blows goats and seems incredibly 'hackish' for built-in classes. (The video illustrates what happens when you make the detail view the root view, then add it back to the split view and make the split view root while in landscape; you get double rotation of the detail view.)
Unfortunately I've again run into these transformation issues while attempting to resize a SplitViewController's detail sub-view in response to the keyboard appearing/disappearing. In portrait, all works fine, in landscape it's fscked.
Yes, adjust the contentInset and scrollIndicatorInsets are the convenient way to resize the UITableView.
As the answer of Sam Soffes posted, I succeed resize UITableView in UITableViewController for the bottom UIToolbar.