0

我是 iPhone 开发者的新手,

我想手动调用构造函数,我应该怎么调用?

这是我的代码片段,

- (id)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {


        CFURLRef pdfURL = CFBundleCopyResourceURL(CFBundleGetMainBundle(), CFSTR("ePubTutorial.epub"), NULL, NULL);
        pdf = CGPDFDocumentCreateWithURL((CFURLRef)pdfURL);
        CFRelease(pdfURL);
        self.pageNumber = 1;
        self.backgroundColor = nil;
        self.opaque = NO;
        self.userInteractionEnabled = NO;
    }
    return self;
}

提前致谢 !!

4

2 回答 2

3

只需使用该初始化方法。例子:

[[yourClass alloc]initWithFrame:yourFrame];

我建议买一些书读一读,它们确实有帮助

于 2012-05-22T11:49:31.123 回答
0

包含init及其名称的方法是iphone中的构造函数。你会称它为

Object* obj = [[Object alloc] initWithFrame:theFram]; 
于 2012-05-22T11:49:48.830 回答