简体   繁体   中英

Xcode 6 Universal storyboard NSKeyedUnarchiver initForReadingWithData error

I've migrated my project from iOS 7 to iOS 8 keeping iOS 7 support. Since i've redone all the graphics i've thrown away the old storyboard and created a new one using the new universal storyboard and size classes.

Everything works fine for iOS 8 iPhone/iPad and iOS 7 iPhone but on iOS 7 iPad i'll keep getting the following error:

[NSKeyedUnarchiver initForReadingWithData:]: data is empty; did you forget to send -finishEncoding to the NSKeyedArchiver?

the app didn't even reach application:didFinishLaunchingWithOptions and i know the problem is the storyboard, because if i create an empty one the app start fine.

What am i missing? Do i need an ad hoc storyboard only for ipad to support iOS 7? or there is another way?

EDIT:

during some test, i've found that the method that throw the exception is:

[storybord instantiateInitialViewController];

or

[storyboard instantiateViewControllerWithIdentifier:@"id"];

i've launched the application with an empty storyboard and loaded my storyboard in the app delegate. The storyboard is not nil, but the app crash on that method. Loading a view controller that is not the initial one doesn't change the result.

I was having this same issue and narrowed it down to a Collection View that I had installed for my compact/any size class, but uninstalled for my any/any size class. It seems that iOS 7 has trouble with prototype cells when the collection view they belong to is uninstalled in the active size class. Running on iOS 8 works fine so if you're only supporting iOS 8 and above, you won't run into this issue.

Prototype cell(s) active (Doesn't work): 带有原型单元的未安装收藏视图

Prototype cell(s) removed (Works): 没有原型单元的已卸载集合视图

To solve this, I'm going to create a xib that will be programmatically loaded for iPad and keep the storyboard for use on iPhone. Since the view in question doesn't need a Collection View on iPad, the xib should be pretty simple, but it still sucks to have to do this from a maintenance standpoint.

I've been finally able to resolve it, i found out that an element with an outlet in a viewController had only the iphone size class (i forgot to add it to the regular\\regular size class) this caused the error.

Adding it to the regular\\regular size class solved the problem

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM