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

そのinitメソッドを使用するだけです。例:

[[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 に答える