1

My app had the default MainWindow.xib with a NavigationController in it. Now I recently switched it to a xib-less main window and RootViewController (subclass of UIViewController) similar to the example provided at the bottom of HelloiPhone:

My Main.cs:

namespace MyApp {
  public class Application {
    static void Main(string[] args) {
      UIApplication.Main(args, null, "MyApp.AppDelegate");
    }
  }

  public class AppDelegate : UIApplicationDelegate {
    UIWindow window;

    // This method is invoked when the application has loaded its UI and its ready to run
    public override bool FinishedLaunching(UIApplication app, NSDictionary options) {
      RootViewController rootViewController = new RootViewController();

      UINavigationController navigationController = new UINavigationController(rootViewController);
      navigationController.LoadView();
      navigationController.NavigationBar.BarStyle = UIBarStyle.Black;

      window = new UIWindow(UIScreen.MainScreen.Bounds);
      window.AddSubview(navigationController.View);
      window.MakeKeyAndVisible();

      return true;
    }

    // This method is required in iPhoneOS 3.0
    public override void OnActivated(UIApplication app) {
    }

    public override void WillTerminate(UIApplication app) {
      //Save data here
    }
  }
}

My Info.plist:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
  <dict>
    <key>UILaunchImageFile</key>
    <string>images/logo_320x480.png</string>
    <key>UIStatusBarStyle</key>
    <string>UIStatusBarStyleBlackOpaque</string>
    <key>UISupportedInterfaceOrientations</key>
    <array>
      <string>UIInterfaceOrientationPortrait</string>
      <string>UIInterfaceOrientationPortraitUpsideDown</string>
    </array>
  </dict>
</plist>

On the simulator, everything seems well. At first, the launching image is displayed and finally the rootView appears after a few seconds.

However, when deploying to the device (iPod touch), the rootView won't display. Instead, the screen turns to white after the launching image. (Status bar at the top is still there)

Is there something wrong with that approach? Am I missing something?

riha
  • 2,270
  • 1
  • 23
  • 40
  • Maybe it will not make any difference, but remove your "navigationController.LoadView();" line. LoadView() is called when you access the View property of a controller and you must not call it yourself. – Dimitris Tavlikos Jan 26 '11 at 09:38

2 Answers2

1

The white screen was not related to switching to xib-less.

The white screen was actually my rootView with white background, some images and some buttons with background images and white font color. I renamed the folder "images" to "Images" a while back and got hit by case-sensitivy on the device. No images displayed and everything else was white so I didn't see it.

If I had tested on the device before switching to xib-less, I could've directly related it to renaming the folder.

riha
  • 2,270
  • 1
  • 23
  • 40
1

You might find some useful info here:

differences-between-iphone-ipod-simulator-and-devices

iphone-device-vs-iphone-simulator

Community
  • 1
  • 1
Josef Van Zyl
  • 915
  • 3
  • 19
  • 43
  • Thanks, those have some useful information. Nothing related though – riha Jan 26 '11 at 11:31
  • OK, it turned out I'm plain stupid. The white screen was not related to switching to xib-less. The white screen was actually my rootView with white background, some images and some buttons with background images and white font color. I renamed the folder "images" to "Images" a while back and got hit by case-sensitivy on the device. No images displayed and everything else was white so I didn't see it. If I had tested on the device before switching to xib-less, I could've directly related it to renaming the folder. – riha Jan 26 '11 at 12:14
  • @riha Well It happens, glad you got it sorted – Josef Van Zyl Jan 26 '11 at 16:30
  • @riha You should actually post your comment as the answer and accept that as it was the correct solution. – Josef Van Zyl Jun 28 '12 at 09:52