DocumentViewController

DocumentViewController

我有2个UIViewController类-DocumentViewController和LibraryViewController。

在DocumentViewController类中,我有以下代码:

- (id)initWithURL:(NSString *)linkToPdf withFileName:(NSString *)fileName{
     //some code goes here ...
}

并且我正在尝试使用代码从LibraryViewController加载DocumentViewController类:
DocumentViewController *documentViewController = [[DocumentViewController alloc] initWithURL:@"http://investor.google.com/pdf/2012Q4_google_earnings_slides.pdf" withFileName:@"Google Earnings Slides"];
[self presentViewController:documentViewController animated:NO completion:nil];

构建时,我在LibraryViewController类中收到一条错误消息:
'DocumentViewController'的可见@interface没有使用initWithURL:withFileName声明选择器:

我该如何解决 ?

最佳答案

检查方法声明是否在DocumentViewController的头文件中。应该是这样

- (id)initWithURL:(NSString *)linkToPdf withFileName:(NSString *)fileName;

10-07 20:05