How to display controllers with proper aligning in iPhone screen?
I have a issue of displaying information in iPhone screen. Case is as follows.
- I crated a vi开发者_JAVA百科ew-based application in Xcode name as myView.
- Then open myViewViewController.xib interface builder, change back groung color and added label at top-let (0, 0) of the view.
- Then I add new file named as myView2ViewController, which is subclass of UIViewController and corresponding XIB also generated.
- Open myView2ViewController in IB and added a label at top-left as previous. Also changed the background color.
In the "applicationDidFinishLaunching" of AppDeligate do following
myView2ViewController *mView = [[myView2ViewController alloc] initWithNibName:@"myView2ViewController" bundle:nil];
[window addSubview:mView.view];
When I run the application, it is shown as upper part of the Label is sheared. It seems as whole UI has been moved 20 px upper (Because, there is a horizontal space in the bottom). I guess this is due to some positioning. But still I could not found any way to fix it.
Hope somebody will help me to identify this issue !!
Check your simulated user interface components in IB. You probably want Status-bar Gray, Top-bar, bottom-bar unspecified. Also check your view lengths are correct : 320x460 if you have a status bar.
Personally, I'd have architected this so that I add mView to myViewController in (say) viewDidLoad, rather than adding it to the window in appDelegate and I'd set mView.frame=CGRectMake(0,0,320,460);
精彩评论