我有一個拆分視圖應用程序,我正在構建,使用plist作爲我的數組,並使用UIWebView在DetailViewController中顯示內容。使用下面的代碼調用我的plist中的URL地址,URL Address通過UIWebView在DetailViewController中顯示PDF。拆分視圖應用程序,在詳細信息視圖中顯示PDF,PDF的本地存儲
DetailViewController.m
NSString *mutareURL = [_detailItem description];
NSURL *url = [NSURL URLWithString:mutareURL];
[_catalog loadRequest:[NSURLRequest requestWithURL:url]];
我需要做的是所有的PDF文件在我的項目我的資源文件夾。我可以爲RootViewController(TableView)使用NSArray或plist,但是我需要能夠在RootViewController(TableView)中選擇Row時通過UIWebView在DetailViewController中顯示PDF。我在我的DetailViewController.m文件中試過這個代碼,但它不工作。
NSString *path = [[NSBundle mainBundle] pathForResource:@"%@" ofType:@"pdf"];
NSURL *targetURL = [NSURL fileURLWithPath:path];
NSURLRequest *request = [NSURLRequest requestWithURL:targetURL];
[_Pdf loadRequest:request];
我有一個NSLog的與此代碼我RootViewController.m文件,我看到的是,PDF文件的名稱都出現在我調試了。我只是不知道如何從RootViewController中獲取它們,並將它們傳遞到pathforResourse「@」%@「ofType:@」pdf「]; area。小冊子是一個包含所有addObject:@」nameofpdfs「的NSArray在流逝。
RootViewController.m
detailViewController.detailItem = [NSString stringWithFormat:@"%@", [brochures objectAtIndex:indexPath.row]];
NSLog(@"Cell created for row: %d", [indexPath row]);
NSLog(@"brochures = %@", detailViewController.detailItem);
謝謝
非常感謝你,我不知道,我可以把self.detailItem in。我必須使用nil作爲ofType。 – Rogerpn 2011-05-15 18:57:32