我正在使用iPhone APP来显示多个PDF文档。
我有一个UItableview显示来自.plist的我的pdf文件的名称,我有开源的VFR pdf阅读器(https://github.com/vfr/Reader)。
我知道如何从带有动作的UI按钮连接到vfr-reader:
- (IBAction)didClickOpenPDF1SEMCYTO {
NSString *file = [[NSBundle mainBundle] pathForResource:@"1SEMCYTO" ofType:@"pdf"];
ReaderDocument *document = [ReaderDocument withDocumentFilePath:file password:nil];
if (document != nil)
{
ReaderViewController *readerViewController = [[ReaderViewController alloc] initWithReaderDocument:document];
readerViewController.delegate = self;
readerViewController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
readerViewController.modalPresentationStyle = UIModalPresentationFullScreen;
[self presentModalViewController:readerViewController animated:YES];
和
- (void)dismissReaderViewController:(ReaderViewController *)viewController {
[self dismissModalViewControllerAnimated:YES];}
显然我需要类似的东西,但我无法弄清楚如何/什么,这是唯一真正相似的主题,Custom UITableViewCell and IBAction
但是我无法弄清楚我是否可以使用这种方法,
任何想法请帮忙吗?
答案 0 :(得分:0)
对于表视图,每次点击一行时,都会调用表视图didSelectRowAtIndexPath的委托方法。 (More about UITableViewDelegate)
使用indexPath参数,尤其是下面方法中传递的行,以确定需要在ReaderViewController中显示哪个PDF。
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
// Navigation logic may go here. Create and push another view controller.
ReaderViewController *readerViewController = [[ReaderViewController alloc] initWithReaderDocument:document];
readerViewController.delegate = self;
//determine the PDF to be shown based on indexPath.row
readerViewController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
readerViewController.modalPresentationStyle = UIModalPresentationFullScreen;
[self presentModalViewController:readerViewController animated:YES];
}
请记住将表视图委托设置为实现上述方法的视图控制器,就像设置ReaderViewController的委托一样。