我的以下代码一切都在 AppDelegate.m
中我的 Xcode 项目的文件。
#import "AppDelegate.h"
#import "NavigationViewController.h"
#import "HubViewController.h"
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.rootViewController = [[NavigationViewController alloc] initWithRootViewController:[[HubViewController alloc] init]];
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return YES;
}
@end
我在
'self.window.rootViewController' line stating 'No visible @interface for NavigationViewController' declares the selector 'initWithRootViewController:'
上不断收到错误消息.它还在错误日志中将其声明为 1ARC Issue1。 (自动引用计数问题)。是否有任何已知的解决方案可以解决这个问题?
最佳答案
我猜你刚刚开始使用 Objective-c 和 iOS 开发。您可以创建自己的 NavigationViewController 类,但您可能打算做的是使用 UINavigationController - 这是一个预装的容器 View Controller ,用于处理推送/弹出式导航。它经常用作应用程序中的根 View Controller 。
背景颜色:
您的导航 Controller 的 View 将消耗整个 frame的 window 。所以你应该设置:
self.window.rootViewController.view.backgroundColor = [UIColor whiteColor];
ARC 错误:
对于 ARC 错误,您需要发布更多信息。
iTunes U:
我建议您从 iTunes U 下载并观看 iOS 斯坦福大学 iOS 编程类(class)。这是一个很好的介绍,而且是免费的。
关于ios - 'NavigationViewController' 没有可见的@interface 声明了选择器 'initWithRootViewController:',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19192558/