开发者

How to display controllers with proper aligning in iPhone screen?

I have a issue of displaying information in iPhone screen. Case is as follows.

  1. I crated a vi开发者_JAVA百科ew-based application in Xcode name as myView.
  2. Then open myViewViewController.xib interface builder, change back groung color and added label at top-let (0, 0) of the view.
  3. Then I add new file named as myView2ViewController, which is subclass of UIViewController and corresponding XIB also generated.
  4. Open myView2ViewController in IB and added a label at top-left as previous. Also changed the background color.
  5. 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);

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜