ios - 用于打印的弱链接框架

标签 ios printing weak-linking

我有一个使用邮件和打印例程的简单项目。对于打印,我有一个 UIPrintPageRenderer 的子类。我正在关注 Apple 的 guidelines使用弱链接类:

- The base SDK for your Xcode project must be iOS 4.2 or newer. The name for this setting in the build settings editor is SDKROOT (Base SDK).
- The deployment target for your project must be iOS 3.1 or newer. The name for this setting is MACOSX_DEPLOYMENT_TARGET (Mac OS X Deployment Target).
- The compiler for your project must be the LLVM-GCC 4.2 compiler or newer, or the LLVM compiler (Clang) 1.5 or newer. The name for this setting is GCC_VERSION (C/C++ Compiler Version).
- You must ensure that any frameworks not available in your project’s deployment target are weakly linked, rather than required. See “Weak Linking to an Entire Framework” and “Linking Libraries and Frameworks” in Xcode Project Management Guide.

问题

我在应用程序启动时仍然遇到错误:

2011-07-08 10:47:19.819 MyTestProject[47013:207] *** -[UIWindow setRootViewController:]: unrecognized selector sent to instance 0x5a2aac0
2011-07-08 10:47:19.821 MyTestProject[47013:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[UIWindow setRootViewController:]: unrecognized selector sent to instance 0x5a2aac0'
2011-07-08 10:47:19.822 MyTestProject[47013:207] Stack: (
    43358288,
    44516140,
    43367003,
    42829430,
    42826226,
    9319,
    1149252,
    1153359,
    1178942,
    1160439,
    1192408,
    47780220,
    42637468,
    42633384,
    1151521,
    1184626,
    9129,
    8997
)
terminate called after throwing an instance of 'NSException'

当我尝试为 iPad 3.2 模拟器运行我的应用程序时,我得到了这个。知道为什么吗?

附注代码适用于 iPad 4.2 和 4.3。

最佳答案

来自documentation对于 UIWindowrootViewController 属性仅适用于 iOS 4.0 及更高版本(因此,setRootViewController 也是如此):

rootViewController

The root view controller for the window.

@property(nonatomic,retain) UIViewController *rootViewController

Discussion

The root view controller provides the content view of the window. Assigning a view controller to this property (either programmatically or using Interface Builder) installs the view controller’s view as the content view of the window. If the window has an existing view hierarchy, the old views are removed before the new ones are installed.

The default value of this property is nil.

Availability

Available in iOS 4.0 and later.

这就是为什么您的应用程序在 iOS 3.2 上崩溃,但在 iOS 4.2 和 4.3 上却不会。

关于ios - 用于打印的弱链接框架,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6620259/

相关文章:

ios - 查找是否已存在 Google+、Fb、Linkedin 和 Twitter 应用

c - 一个 float 在 C 中打印正常,另一个则不行

c# - 如何从打印机变量中获取纸张大小?

c - 共享对象中的弱链接未按预期工作

检查 C 中外部定义的标识符是否存在

ios - 在 iOS 中解析 excel 文件

ios - 解析 JSON Swift 2.0

ios - 从线程调用 View Controller 的方法

windows - 批处理脚本: open the printingtool Windows

iphone - iPhone 上的弱链接无法正常工作