我的應用程序有一個默認的MainWindow.xib與NavigationController在其中。現在,我最近就切換到類似於在HelloiPhone底部提供的一個例子廈門國際銀行少主窗口和RootViewController的(UIViewController的子類):應用程序在模擬器中工作,在設備上的白色屏幕
我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
}
}
}
我的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>
在模擬器上,一切都很順利。首先,顯示啓動圖像,最後在幾秒鐘後出現rootView。
但是,當部署到設備(iPod touch)時,rootView將不會顯示。相反,屏幕在啓動圖像後會變成白色。 (頂部的狀態欄仍然存在)
這種方法有什麼問題嗎?我錯過了什麼嗎?
也許它不會有任何區別,但刪除你的「navigationController.LoadView();」線。當您訪問控制器的視圖屬性時調用LoadView(),並且您不能自己調用它。 – 2011-01-26 09:38:57