gpt4 book ai didi

iphone - ios : add printing, 但保持与 ios 3 的兼容性

转载 作者:行者123 更新时间:2023-12-03 19:07:14 25 4
gpt4 key购买 nike

我正在尝试向 iOS 应用程序添加打印功能。虽然打印本身工作正常,并且该应用程序可以在 ios > 4 上运行,但我还没有弄清楚如何保持 ios 3.1 兼容性...

我猜问题是这样的:completionHandler:(UIPrintInteractionCompletionHandler)

A block of type UIPrintInteractionCompletionHandler that you implement to handle the conclusion of the print job (for instance, to reset state) and to handle any errors encountered in printing.

一旦我添加了 block :

void (^completionHandler)(UIPrintInteractionController *, BOOL, NSError *) =
^(UIPrintInteractionController *printController, BOOL completed, NSError *error) {
};

该应用程序甚至无法在 iOS 3.1 上启动可能是因为那里没有可用的 block 。

是的,我确保此代码在 iOS 3.1 上启动时不会运行...

if (([[[UIDevice currentDevice] systemVersion] floatValue] >= 4.2) && ([UIPrintInteractionController isPrintingAvailable]))

所以我想知道是否有办法为 iOS >4.2 提供打印支持,但保持它在 iOS 3.1 上运行?

也许有一种方法可以使用方法而不是“ block ”?或者如何才能在支持的 iOS 设备上进行打印,并保持向后兼容 iOS 3.1?

最佳答案

只需将 -weak_framework UIKit 添加到“其他链接器标志”下的项目设置中,并确保使用条件代码来打印 API。条件代码应检查功能可用性,而不是操作系统版本:

    if (NSClassFromString(@"UIPrintInteractionController")){
void (^completionHandler)(UIPrintInteractionController *, BOOL, NSError *) =
^(UIPrintInteractionController *printController, BOOL completed, NSError *error) {
};
}

将您的项目目标设置为 iOS 3,然后就可以开始了。

关于iphone - ios : add printing, 但保持与 ios 3 的兼容性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4297723/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com