iOS UI学习笔记——错误纪录及解决方法

来源:互联网 发布:中国森林覆盖率 知乎 编辑:程序博客网 时间:2024/04/30 13:25
错误问题1:
Terminating app due to uncaught exception'NSGenericException', reason: 'Push segues can only be used when the sourcecontroller is managed by an instance of UINavigationController.

  这个错误的意思是,在连接两个viewController的时候,使用了“push”的方式,但是源viewController不是UINavigationController的实例,所以异常,程序终止。

  解决这个错误有两种方法:

  第一个:是在用“Ctrl”连接两个viewcontroller的时候,不要用“push”的方式,而用“modal”的方式。


  第二个:就是添加一个UINavigationController咯。
错误问题2:
Failed to instantiate the default view controller for UIMainStoryboardFile 'MainStoryboard' - perhaps the designated entry point is not set?

原因分析:在StoryBoard中没有一个view controller设置了Initial Scene。

解决方案:在Storyboard中,选择一个view conroller作为story board的第一启动界面



如果你想通过代码来打开另外一个界面,则需要设置他们之间连接的segue.identifier,比如你设置为jumpid。

然后代码就可以这么写:


self.performSegueWithIdentifier("jumpid", sender: self);

如果你还想在跳转的时候传递数值过去,你可以这么写:

override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {

        if(segue.identifier == "jumpid") {

            var barInfo:BarInfoViewController = segue.destinationViewController as! BarInfoViewController;

            barInfo.name = "david";

            barInfo.age = 99;

        }


    }

错误问题3:
Could not load the "angry_00.jpg" image referenced from a nib in the bundle with identifier 
问题解决:拖动图片文件夹的时候选项中选择Create groups for any added folders
错误问题4:
this class is not key value coding-compliant for the key sumLabel.
问题解决:连线有问题

0 0