MFMailComposeViewController和SKStoreProductViewController的init方法发生iOS崩溃

MFMailComposeViewController和SKStoreProductViewController的init方法发生iOS崩溃,ios,objective-c,ios7,crash,unrecognized-selector,Ios,Objective C,Ios7,Crash,Unrecognized Selector,我正在开发一个部署目标为7.0的iOS应用程序,并尝试在应用程序中提供内置的视图控制器,如MFMailComposeViewController和SKStoreProductViewController。但是,当我初始化任何内置视图控制器并显示以下错误消息时,我的应用程序就会崩溃: [__NSGlobalBlock__ encodeWithCoder:]: unrecognized selector sent to instance 0x57986c 碰撞发生在以下几行: MFMailComp

我正在开发一个部署目标为7.0的iOS应用程序,并尝试在应用程序中提供内置的视图控制器,如MFMailComposeViewController和SKStoreProductViewController。但是,当我初始化任何内置视图控制器并显示以下错误消息时,我的应用程序就会崩溃:

[__NSGlobalBlock__ encodeWithCoder:]: unrecognized selector sent to instance 0x57986c
碰撞发生在以下几行:

MFMailComposeViewController* controller = [[MFMailComposeViewController alloc] init];

我找不到这个错误的任何线索。我正在使用一些第三方播客,如KeepLayout和ReactiveCocoa,其中包括UIView元素的一些类别。不确定这是否是问题的根源

以下是由[SLComposeViewController ComposeViewController ForService Type:SLServiceTypeTwitter]引起的崩溃的堆栈跟踪

0 CoreFoundation 0x103c0d47d __exceptionPreprocess + 141
1 libobjc.A.dylib 0x10396c99e objc_exception_throw + 43
2 CoreFoundation 0x103c9e65d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3 CoreFoundation 0x103bfed8d ___forwarding___ + 973
4 CoreFoundation 0x103bfe938 _CF_forwarding_prep_0 + 120
5 Foundation 0x101af43ef _encodeObject + 1150
6 Foundation 0x101af770f +[NSKeyedArchiver archivedDataWithRootObject:] + 162
7 UIKit 0x102cb841c -[_UIAppearanceRecorder _recordInvocation:withClassName:containerClassNames:selectorString:forRemoteProcess:] + 2450
8 UIKit 0x102cb3ff1 __54+[_UIAppearance _recordersExcludingSource:withWindow:]_block_invoke + 838
9 CoreFoundation 0x103c8c10f __65-[__NSDictionaryM enumerateKeysAndObjectsWithOptions:usingBlock:]_block_invoke + 111
10 CoreFoundation 0x103c8c01e -[__NSDictionaryM enumerateKeysAndObjectsWithOptions:usingBlock:] + 206
11 UIKit 0x102cb3c99 +[_UIAppearance _recordersExcludingSource:withWindow:] + 137
12 UIKit 0x102e20c9c UIViewServiceCurrentAppearanceSerializedRepresentations + 77
13 UIKit 0x102d58038 +[_UIRemoteViewController requestViewController:fromServiceWithBundleIdentifier:connectionHandler:] + 197
14 Social 0x102626410 -[SLComposeViewController loadServiceViewControllerWithClassName:fromServiceBundleWithIdentifier:] + 172
15 Social 0x102623ec6 -[SLComposeViewController initWithServiceViewControllerClassName:hostingBundleIdentifer:] + 126
16 Social 0x102623d71 -[SLComposeViewController initWithServiceType:] + 267
17 Social 0x102624130 +[SLComposeViewController composeViewControllerForServiceType:] + 65

您需要将MessageUI和StoreKit框架添加到项目中。(在构建阶段->将二进制文件链接到库中)

此错误的典型原因是当您尝试归档未实现NSCoding的对象时。两个内置vc都不会这么做。你做过任何存档吗,或者你使用的第三方lib?我看不出有任何理由在这些VC init方法中进行存档。我怎么知道呢?我不是建议您应该归档,而是建议您的代码在某个地方试图归档一个块(它不应该这样做)。在您的项目中尝试全局搜索“encode”(使用包含匹配)。@danh好吧,但是在内置VC的init方法中怎么会发生这种情况?问题将是由于其他原因造成的。。。它似乎就在那里显现出来了。尝试替换UIViewController aloc init。我打赌你到时候也会看到的。它们已经包含在构建阶段和我的Objective-C文件的头中。我仍然会遇到这个错误。@Peyman你在任何地方用NSDictionary配置UIAppearance吗?我不知道。我的代码中唯一使用UIAppearance的是BButton和SVProgressHUD第三方CoCoCoca控件。
0 CoreFoundation 0x103c0d47d __exceptionPreprocess + 141
1 libobjc.A.dylib 0x10396c99e objc_exception_throw + 43
2 CoreFoundation 0x103c9e65d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3 CoreFoundation 0x103bfed8d ___forwarding___ + 973
4 CoreFoundation 0x103bfe938 _CF_forwarding_prep_0 + 120
5 Foundation 0x101af43ef _encodeObject + 1150
6 Foundation 0x101af770f +[NSKeyedArchiver archivedDataWithRootObject:] + 162
7 UIKit 0x102cb841c -[_UIAppearanceRecorder _recordInvocation:withClassName:containerClassNames:selectorString:forRemoteProcess:] + 2450
8 UIKit 0x102cb3ff1 __54+[_UIAppearance _recordersExcludingSource:withWindow:]_block_invoke + 838
9 CoreFoundation 0x103c8c10f __65-[__NSDictionaryM enumerateKeysAndObjectsWithOptions:usingBlock:]_block_invoke + 111
10 CoreFoundation 0x103c8c01e -[__NSDictionaryM enumerateKeysAndObjectsWithOptions:usingBlock:] + 206
11 UIKit 0x102cb3c99 +[_UIAppearance _recordersExcludingSource:withWindow:] + 137
12 UIKit 0x102e20c9c UIViewServiceCurrentAppearanceSerializedRepresentations + 77
13 UIKit 0x102d58038 +[_UIRemoteViewController requestViewController:fromServiceWithBundleIdentifier:connectionHandler:] + 197
14 Social 0x102626410 -[SLComposeViewController loadServiceViewControllerWithClassName:fromServiceBundleWithIdentifier:] + 172
15 Social 0x102623ec6 -[SLComposeViewController initWithServiceViewControllerClassName:hostingBundleIdentifer:] + 126
16 Social 0x102623d71 -[SLComposeViewController initWithServiceType:] + 267
17 Social 0x102624130 +[SLComposeViewController composeViewControllerForServiceType:] + 65