UITableViewControllers
의 숫자로 드릴 다운하려고합니다. 결국 사용자가 선택한 섹션과 행을 기반으로로드 된 pdf 파일로 이동합니다. 섹션 및 행 정보를 PDFViewController
(작동)에 전달하려고 시도했지만 실제로 선택한 PDF를로드하는 UIScrollView
에 선택한 섹션 및 행 정보를 전달할 수 없습니다. PDFScrollView
이 인스턴스화 될 때 속성을 설정하려고 시도했지만 PDFScrollView
이로드 될 때 해당 값이 유지되지 않습니다. 이제 PDFViewController.mUIViewController에서 UIScrollView 클래스에 속성을 할당하려고 시도합니다.
#import "PDFViewController.h"
#import "PDFScrollView.h"
#import "ProtocolDetailViewController.h"
@implementation PDFViewController
@synthesize detailIndexRow;
@synthesize detailIndexSection;
- (void)loadView {
[super loadView];
// Log to check to see if detailIndexSection has correct value
NSLog(@"pdfVC section %d", detailIndexSection);
NSLog(@"pdfVc row %d", detailIndexRow);
// Create PDFScrollView and add it to the view controller.
PDFScrollView *sv = [[PDFScrollView alloc] initWithFrame:[[self view] bounds]];
sv.pdfIndexSection = detailIndexSection;
[[self view] addSubview:sv];
}
에서
코드 PDFScrollView.m
어디에서 모두 int
및 반환 detailIndexSection
#import "PDFScrollView.h"
#import "TiledPDFView.h"
#import "PDFViewController.h"
#import <QuartzCore/QuartzCore.h>
@implementation PDFScrollView
@synthesize pdfIndexRow;
@synthesize pdfIndexSection;
- (id)initWithFrame:(CGRect)frame
{
// Check to see value of pdfIndexSection
NSLog(@"PDF section says %d", pdfIndexSection);
NSLog(@"PDF row says %d", pdfIndexRow);
if ((pdfIndexSection == 0) && (pdfIndexRow == 0)) {
NSURL *pdfURL = [[NSBundle mainBundle] URLForResource:@"cardiacarrestgen.pdf" withExtension:nil];
pdf = CGPDFDocumentCreateWithURL((__bridge_retained CFURLRef)pdfURL);
}
else if ((pdfIndexSection == 0) && (pdfIndexRow == 1)) {
NSURL *pdfURL = [[NSBundle mainBundle] URLForResource:@"cardiacarrestspec.pdf" withExtension:nil];
pdf = CGPDFDocumentCreateWithURL((__bridge_retained CFURLRef)pdfURL);
}
pdfIndexSection
및 pdfIndexRow
에서 위의 코드에 할당 된 값을 유지하지 않습니다 있습니다 pdfIndexSection
0
은 어떤 섹션이나 행이 didSelectRowAtIndexPath
에서 선택 되더라도 상관 없습니다.
그래서 두 가지 질문 :
나는
ViewController
에sv.pdfIndexSection
에 int 값을 할당 할 때, 그것은ScrollView
의 값을 유지하지 않는 이유.이 개념을 구현하는 더 좋은 방법이 있습니까?
감사합니다. 그것은 완벽하게 이해하고 문제를 해결합니다. 매우 감사! – blueHula