iOS 在 MFMailComposeViewController 和 SKStoreProductViewController 的 init 方法上崩溃

标签 ios objective-c ios7 crash unrecognized-selector

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

[__NSGlobalBlock__ encodeWithCoder:]: unrecognized selector sent to instance 0x57986c

崩溃发生在以下几行中:

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

SKStoreProductViewController *storeViewController = [[SKStoreProductViewController alloc] init];

我找不到任何线索这个错误来自哪里。我正在使用一些第三方 pod,例如 KeepLayout 和 ReactiveCocoa,其中包含 UIView 元素上的一些类别。不确定这是否是此问题的根源。

这是由 [SLComposeViewController composeViewControllerForServiceType: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 框架添加到您的项目中。 (在构建阶段 -> 将二进制文件与库链接)

关于iOS 在 MFMailComposeViewController 和 SKStoreProductViewController 的 init 方法上崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23743055/

相关文章:

ios - 尽管完成了所有必需的设置/过程,UITableViewCell 不会从默认样式更改为副标题

ios - 我可以通过“Windows”计算机在iOS Real设备上运行我的appium代码吗?

iphone - 更改 UIStepper 的大小?

ios - Apple Watch 应用程序无法在不同的模拟器上运行

ios - 如何将我的 UICollectionViewFlowLayout 更改为具有水平滚动的垂直列表

ios - 本地化字符串仅通过 Interface Builder 应用翻译

iPhone 联系人样式应用程序(如何配置标签)

ios - iOS 如何处理低级 C/Objective-C 代码的内存损坏?

swift - 延迟行动

ios - 如何在 iOS 应用程序中减小谷歌地图的屏幕尺寸