打印的弱链接框架

时间:2011-07-08 05:20:17

标签: 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模拟器应用程序时,我得到了这个。知道为什么吗?

P.S。代码适用于iPad 4.2和4.3。

2 个答案:

答案 0 :(得分:3)

UIWindow rootViewController开始,属性setRootViewController仅适用于iOS 4.0及更高版本(因此,@property(nonatomic,retain) UIViewController *rootViewController也是如此):

  

<强> RootViewController的

     

的根视图控制器   窗口。

     

{{1}}

     

讨论

     

根视图控制器提供   窗口的内容视图。分配   此属性的视图控制器   (以编程方式或使用   Interface Builder)安装视图   控制器的视图作为内容视图   的窗口。如果窗口有   现有视图层次结构,旧视图   在新的之前删除   安装。

     

此属性的默认值为   零。

     

状况

     

适用于iOS 4.0及更高版本。

这就是你的应用程序在iOS 3.2上崩溃的原因,但不适用于iOS 4.2和4.3。

答案 1 :(得分:0)

我不认为您可以在低于4.2的iOS上打印而无需任何其他服务。在iOs 4.2或更高版本上,有预装的打印机驱动程序(如果我没记错的话)支持AirPrint。在较低的iO上,这些驱动程序未安装且无法安装。

来自:How to Print a document from iphone below ios version 4.2