IOS StoryBoard修改对于真机无效的问题

来源:互联网 发布:js调用ajax方法 编辑:程序博客网 时间:2024/06/06 23:39

        今天调试IOS代码,一直提示“has no segue with identifier” 的错误。更加诡异的是,在模拟器上调试一切正常,在真机上调试才会出这个错误。开发IOS相当一段时间,对于storyboard中segue的操作、页面的跳转估计已经做过上百次,所以不觉得自己会漏写identify或者对destination view和resource view的设置产生错误。不过还是检查了两遍,的确没错。于是上网找了好多资料,各种各样的“has no segue with identifier”,基本上都是出于以上提到的两点,但是自己的确没有写错。如果有错,那么为什么模拟器是正常的?

        这个问题花了我相当长的时间,直到看到一篇帖子的回帖。

I had the same problem and struggled with it for hours. Stackmonster's answer solved my problem (rename the storyboard), but I didn't understand why it solved the problem.

I found that when I changed an item on the storyboard (added a label or changed background colour) it was not reflected in the simulator - I wasn't using the storyboard that I could see in xcode, but an older version of the storyboard. I had to rename the storyboard in the project navigator and also rename it in the info.plist (in supporting files) and my label appeared, and the background colour applied, and the segue worked.

I don't know why the storyboard changes weren't taking effect, but it caused me a huge amount of time to find. I've seen on the blogs that a lot of devs have the same problem.

意思是他对storyboard的修改并没有在程序中生效。很有可能跟我的错误一致,也就是说我在storyboard中写了segue,但是并没有在真机上生效,而在模拟器上是可以用的。奇了怪了,那么真机和模拟器有什么不同,只有一个是中文版本,一个是英文版本。突然想起来前几天做过汉化。于是点开来storyboard,下面居然出现了两个子成员。


具体点开那个chinese,里面果然没有我修改过的segue,两个子成员居然可以不同。修改之后一切正常。

IOS这个功能真是太坑了,何必两个要弄成不一样。即使汉化,也没必要弄个storyboard副本吧。


原创粉丝点击