[轉]application windows are expected to have a root view controller錯誤

來源:互聯網
上載者:User

標籤:class   blog   code   http   com   strong   

轉載地址:http://blog.sina.com.cn/s/blog_6784e6ea01017jfy.html

最新更正:這個提示幾乎不影響編譯和運行,可以不用設定。  

產生這個提示的操作:在xcode4.6中建立一個名字為appTest空工程,create一個ios-application-empty application,直接編譯運行

 錯誤提示:雖然編譯通過,也能運行,但是底下有錯誤提示“application windows are expected to have a root view controller” 原因:在較新的xcod上都會出現這種錯誤。在iOS5之前的版本,應用載入時,需要一個root view controller,在iOS5以下的版本會有MainWindow作為開機檔案,iOS5以後的版本沒有了。需要手動建立一個root view controller 解決:①建立一個類file - new file - object-c class,名字myViewController,繼承於UIViewController②在testAppDelegate.h中添加屬性viewController,代碼如下:@property (strong, nonatomic) myViewController* viewController ③在testAppDelegate.m中初始化viewController並賦值給rootViewControllerself.viewController = [[ViewController alloc] initWithNibName:@"myViewController" bundle:nil];self.window.rootViewController = self.viewController; 再次編譯運行已經沒有錯誤了。   
相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.