2013-10-05 40 views
1

我的下面的代碼一切都在我的Xcode項目的AppDelegate.m文件中。'NavigationViewController'沒有可見的@interface聲明選擇器'initWithRootViewController:'

#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。 (自動引用計數問題)。有沒有解決這個問題的方法?

回答

3

我猜你剛剛開始使用objective-c和iOS開發。你可以創建你自己的NavigationViewController類,但是你可能打算做的是使用UINavigationController - 這是一個預先封裝的容器視圖控制器,可以處理push/pop樣式的導航。它經常用作應用程序中的根視圖控制器。

背景顏色:

你導航控制器的觀點是要消耗窗口的整個frame。所以,你應該改爲設置:

self.window.rootViewController.view.backgroundColor = [UIColor whiteColor]; 

ARC錯誤:

對於ARC錯誤,您需要發佈更多信息。

的iTunes U:

我建議你下載並觀看從iTunes U. iOS的斯坦福Univserity iOS的編程當然,這是一個偉大的介紹,並且免費。

+0

感謝您的回覆! –

相關問題