初学ios遇到问题记录01

刚刚接触IOS,花了一段时间看我基础部分的OC后

就想试着弄个小程序,于是看到 http://www.cnblogs.com/LooDo/p/3907064.html博文中的小程序,博主分析的很详细,自己也想练手试试看,遇到

Application windows are expected to have a root view controller at the end of application launch

这个问题,一直调试不通代码。

归咎原因:

博主用的xcode版本是4.2版本以前的版本,而我是新手才入手买的Mac Pro 装得xcode自然也是最新的5.1版本。

xcode 4.2 不再支持 Window-Based Application 模板创建项目 。导致自己新建的项目中得MainWindow.xib文件中得window无法与委托中插座变量window关联起来。所以程序运行起来,调试时发现该变量window的值一直为空,以下是解决方法。 按照如下步骤来做,程序是能调试通过的。

 1.Ctrl+N,创建User Interface下面的Window(选择“iOS->User Interface->Window),命名成MainWindow.xib。
 2.File Owner修改成UIApplication。(即调出show identity inspector面板,将file's Owner的属性Custom Class中将class改为UIApplication。)


  4.从Library库中,拖个Object出来添加,并修改类为Delegate的那个类,最开始自动生成的那个。(即将新添加的Object的Class改为AppDelegate)



     5.把Delegate类的属性window声明加上IBOutlet,这样才好在IB里面连接。(即将AppDelegate中UIWindow属性标记为IBOutlet)

        即@property (strong,nonatomic) UIWindow *window;修改为:@property (strong, nonatomic) IBOutlet UIWindow *window;

    然后,把MainWindow.xib的FileOwner的delegate设置为你的AppDelegate。FileOwner的delegate和AppDelegate(Object)连接:(蓝色连线哦)


       把Window和你AppDelegate中的Outlet关联起来:

上图即AppDelegate的outlets和Window连接起来。
     6.(可以看到,已经有一个Window对象,此window对象就是iphone的屏幕。)把window属性连接到IB中默认出现的Window。
     

 7.关键一个步骤,打开项目属性,在Summary下面的Main Interface里面选择MainWindow完事。

原文地址:https://www.cnblogs.com/zendwang/p/3915983.html