0

I created a simple view based application using Xcode and I tried using CGPDFDocumentGetMediaBox method as below:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    

// Override point for customization after application launch.

// Set the view controller as the window's root view controller and display.
CGPDFDocumentRef r;
CGRect cg = CGPDFDocumentGetMediaBox(r, 0);
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];

return YES;
}

However, I get a compile error saying that the method is unavailable:

/Users/s/Documents/test/Classes/testAppDelegate.m:27:0 /Users/s/Documents/test/Classes/testAppDelegate.m:27: error: 'CGPDFDocumentGetMediaBox' is unavailable (declared at /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.3.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CGPDFDocument.h:117)

I can see from the Apple documents- Deprecated in Mac OS X version 10.3 and later. But doesn't deprecated mean that the methods should no be used but are still available? I can see the declaration in the header file: CGPDFDocument.h

Mac version: 10.6.8 Xcode version: 3.2.6 iOS SDK: 4.3

Am I missing something here?

4

1 回答 1

1

改为使用CGPDFPageGetBoxRect(page, kCGPDFMediaBox)。请注意,它需要 aCGPDFPageRef而不是 a CGPDFDocumentRef。这是因为不同的页面可能有不同的媒体框。如果您确定文档的页面大小相同且布局相同,则可以只使用文档的第一页(通过CGPDFDocumentGetPage(document, 1).)

于 2012-04-13T19:26:05.893 回答