ios - 'NavigationViewController' 没有可见的@interface 声明了选择器 'initWithRootViewController:'

标签 ios objective-c

我的以下代码一切都在 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/

相关文章:

ios - multipart/form-data 的 AFNetworking 日志请求正文

ios - 如何对 Sprite 工具包中的整个类别位掩码应用脉冲

objective-c - 使用 NSFileManager 访问 mac 共享上的文件

ios - 尝试在异常 : _descendantWillPresentViewController 中呈现模态结果

iphone - 索引对象矩阵 (UILabel)

ios - 如何将 TableView 动态单元格链接到特定的 View Controller ?

ios - iOS app bundle id 中的 "com."部分重要吗?

ios - 是否可以使用 CoreBluetooth 找到 3.0 蓝牙设备?

ios - 使用 firebase 和 Objective C 不接收推送通知

objective-c - 触摸移动 CAEmitterLayer 在触摸点后立即延迟...