UITableView first row is cut off - objective-c

What would cause the first row of a table in a nav controller to be positioned so part of it is under the nav controller?
I cannot seem to get it to show the whole row top to bottom; It may seem minor, but it's clearly not correct and I find it unattractive.
TableViewController added to nav controller entirely in code:
SettingsRootController*settings=[[SettingsRootController alloc] initWithStyle:UITableViewStylePlain];
self.settingsView=[[[UINavigationController alloc] initWithRootViewController:settings]autorelease];
[settings release];
SettingsRootController is a subclass of UITableViewController.

It seems that it is a common problem with programmatically-added UINavigationController - see Adding a UINavigationController as a subview of UIView.
Basically, what you should probably do is to set the frame property of UINavigationController before you add it as a subview to anywhere. In the accepted answer to the above question there's also a suggestion to alter the UINavigationController's frame to:
nav.view.frame = CGRectMake(nav.view.frame.origin.x, nav.view.frame.origin.y - 20,
nav.view.frame.size.width, nav.view.frame.size.height);

the only thing that seems to work is manually shifting the table view inside the nav controller down by 10 pixels, but only on iPhone, not on iPad, since there is no alignment problem on iPad and shifting by 10 pixels on iPad creates a gap. this is clearly some sort of nav controller bug, as there are other weird issues noted in other threads.
CGPoint tableorigin=CGPointMake(0,ISIPAD?0:10);

Related

How to make current view a scrollview? iOS / Objective C

I have a view (that is actually part of a UINavigationControllers view) that i want to make a scrollview.
how do i do that?
could i do something like this:
UIScrollView * content = [[UIScrollView alloc] initWithFrame:self.view.bounds];
self.view = content
(obviously that doesn't work, but is there a way to do it like that)?
Yes, it is, you have to implement delegates, and set the contentSize. The best tutorial on scrollViews ever I found is:
http://www.raywenderlich.com/10518/how-to-use-uiscrollview-to-scroll-and-zoom-content
You are on a good way!
You can create the scroll view programmatically like you do and then add the existing view as a subview of this new scroll view, examine addSubview: (which works on all UIViews and subclasses like UIScrollView as well). I won't say this is the solution or even a clean one for that matter, but if you read about addSubview: you can at least figure out how to have a view live inside a scroll view...

iPad: UISplitViewController top gets cut off inside UITabViewController

I have a UITabViewController which contains a UISplitViewController as the first view. When the app loads and shows the split controller, the top of the two views are cut off and shifted down a maybe 15 pixels. Clicking another tab fixes the problems and jumps both views back up:
When app loads:
After clicking another tab problem is corrected:
Code being used (unimportant stuff left out):
NewsSplit *newsTemp = [[NewsSplit alloc] init];
...
// The view controllers to the tabBar
[tabController setViewControllers:[NSArray arrayWithObjects:newsSplit, eventSplit, classesSplit, dirSplit, settings, nil]];
...
self.window.rootViewController = self.tabController;
[self.window makeKeyAndVisible];
Why would the top be cut off and shifted down?
The short of it is that UISplitViewController isn't supposed to be embedded within another view controller. It's meant to be the root view controller of your window. I've run into this exact same issue in the past. Support for things such as rotation was glitchy. I eventually got it working like I wanted, but it was a hassle.
Unless they've improved things, I think you're going to have to subclass some things and shift frames around to get it to look right.

iPhone view controller view shifted down 20 pixels when rotating to landscape

I am trying to implement a custom tabbarcontroller using a UIViewController and a UITabBar. Everything is working fine so far, except when I rotate the device to landscape, the UIViewController shifts the entire view down 20pixels, creating a black bar between the status bar and the view. Even when the view is rotated back to portrait orientation, the view is still shifted down 20pixels.
What do I need to do to remove the black bar? Do I have to perform custom rotations? If so, where should I insert these rotations?
Before rotation:
After rotation:
I've experienced this same issue.
This discussion was helpful: UIWebView on iPad size
Tony's answer helped me discover that when you create a subview it's helpful to setup code similar to this:
UIWebView *webView = [[UIWebView alloc] init];
webView.frame = self.view.bounds;
If you post some of your code I may be able to provide more specific advice.
Rather than shifting all views down, try DELTA properties in Interface builder.

UITabBar appears 20 pixels down?

I have created a UITabBarController and adding to a UIViewController subview.
My code is implemented programmatically.
The UITabBar is showed up 20pixels down the view.
UITabBarController *tabCtrl_obj = [[UITabBarController alloc]init];
[self.view addSubview:tabCtrl_obj.view];
How should i solve it?
It's the status bar that's doing it. Sometimes if you add a view directly to the window it can behave oddly - generally it means you have to define more elements of the view yourself. Try reducing the size of your view by 20 pixels (probably to 460) and then removing the simulated status bar in interface builder. How much are you doing programmatically?

Handle touch events when UITableView placed over UITableView

I have a SplitViewController with a UITableView on the left.
I am trying to place a small UITableView over a part of the screen, but touches seem to be handled strangely when the small UITableView is placed over the left UITableView.
I am placing the UITableView over the SplitView like this:
MenuViewController *menu = [[MenuViewController alloc] initWithNibName:nil bundle:nil];
[self.splitViewController.view addSubview:menu.view];
Some touches are registered by menu.view, while sometimes I am able to scroll the underlying view "through" menu.view.
So my question is: what decides which view reacts to touch events?
So I found that the solution was, that I needed to set clipsToBounds=YES on the views contained in menu.view.
Not sure I fully understand the solution, but it works.