我有这个问题,但是我在这个论坛或一般互联网上找不到的信息似乎都无法帮助我.
I have this problem, however none of the information I can find on this forum or the internet in general seems to be able to help me.
似乎有两个地方会出现此错误:
There seem to be two places where this error can come about:
int main(int argc, char *argv[])
{
@autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
}
}
UIApplicationMain 中的最后一个参数返回我的 AppDelegate 类的 NSString 值.因此,这工作正常.
The last argument in UIApplicationMain returns an NSString value of the class of my AppDelegate. This is therefore working fine.
2.AppDelegate.m - 有一种旧"的方式来设置根视图控制器,如下所示:
2.AppDelegate.m - there is an "older" way of setting the root view controller which is like this:
[self.window addSubview:rootViewController];
但是,在我的应用中,它已经更新为:
However, in my app it has already been updated to:
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
因此,互联网上的当前信息均无效.这有点令人费解,因为我的同事可以让它在他的计算机上完美运行 - 他是向我发送应用程序源代码的人,因此所有设置和代码应该完全相同.
So none of the current information on the internet works. It is slightly more puzzling as my colleague can get it to work on his computer perfectly fine - he was the one that sent me the app source code so all the settings and code should be exactly the same.
我正在尝试在模拟器中启动它.它是针对 iOS 5 构建的,但我正在尝试在 iOS 6.0 模拟器上运行它.
I am trying to launch this in the simulator. It is built against iOS 5, but I'm trying to run it on the iOS 6.0 simulator.
我有最新的 XCode (4.5.1).
I have the latest XCode (4.5.1).
有什么原因会发生这种情况吗?我该如何纠正它?
Is there any reason this would be happening? And how can I rectify it?
非常感谢
汤姆
我在尝试将 UITableView 添加到单视图应用程序时遇到了完全相同的事情.相反,创建一个默认的 Master-Detail Application 项目(file->new->target->...)并查看 AppDelegate 的 didFinishLaunchingWithOptions 实现:
I ran into exactly the same thing trying to add a UITableView to a single-view app. Instead, create a default Master-Detail Application project (file->new->target->...) and see the AppDelegate's implementation of didFinishLaunchingWithOptions:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
MDMasterViewController *masterViewController = [[MDMasterViewController alloc] initWithNibName:@"MDMasterViewController" bundle:nil];
self.navigationController = [[UINavigationController alloc] initWithRootViewController:masterViewController];
self.window.rootViewController = self.navigationController;
[self.window makeKeyAndVisible];
return YES;
}
与其直接将视图控制器设置为窗口的 rootViewController,不如为 initWithRootViewController 创建一个使用视图控制器初始化的导航控制器,然后将该导航控制器设置为窗口的 rootViewController.(请注意,您还必须将导航控制器隐藏在属性中,以免被破坏).
Rather than directly setting your view controller as the window's rootViewController, you need to create a navigation controller init'ed with your view controller for initWithRootViewController, then set that nav controller as the window's rootViewController. (Notice you also have to squirrel away that nav controller in a property so it doesn't get destructed).
这篇关于应用程序窗口应该在应用程序启动结束时有一个根视图控制器 - 即使所有已知问题都已修复的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
在没有应用程序源代码的情况下使用 Instruments 测Using Instruments to test an iOS app without having source code to the application(在没有应用程序源代码的情况下使用 Instruments 测试
KIF:如何自动运行/压力测试 iOS 应用程序以找出罕KIF: How to auto-run/stress test an iOS app to find the cause of a rare UI bug?(KIF:如何自动运行/压力测试 iOS 应用程序以找出罕见 UI 错
无法更改 Xcode 4.5 中的目标成员身份可见性Can#39;t change target membership visibility in Xcode 4.5(无法更改 Xcode 4.5 中的目标成员身份可见性)
UITableView:在混合单元格表视图静态和动态单元格UITableView: Handle cell selection in a mixed cell table view static and dynamic cells(UITableView:在混合单元格表视图静态和动态单元格中
如何在 iOS 中删除 Safari 中的地址栏?How to remove Address Bar in Safari in iOS?(如何在 iOS 中删除 Safari 中的地址栏?)
升级到 Xcode 4.5 后,iOS 5 SDK 消失了iOS 5 SDK is gone after upgrade to Xcode 4.5(升级到 Xcode 4.5 后,iOS 5 SDK 消失了)