0

このコードをアプリに入れました:

-(void)setup {
    [self setNeedsDisplay];
    NSLog(@"Test 1");

}

-(void)drawRect:(CGRect)rect {
    NSLog(@"Test 2");
}

NSLog で一連のテスト 1 を取得しますが (これは UITableViewCell であるため)、どの時点でもテスト 2 は取得しません。

4

1 に答える 1

3

ここでサンプル プロジェクト TableViewSuite (CustomTableViewCell プロジェクト) をダウンロードしました: https://developer.apple.com/library/ios/#samplecode/TableViewSuite/Introduction/Intro.html ログ ステートメントを TimeZoneCell クラスに追加することができました。出力を得ることができます。これを見てみると、あなたの質問に答えるのに役立つでしょうか?

#import "TimeZoneCell.h"
#import "TimeZoneWrapper.h"
#import "TimeZoneView.h"
#import "CustomTableViewCellAppDelegate.h"


@implementation TimeZoneCell

@synthesize timeZoneView;


- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {

    if (self = [super initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuseIdentifier]) {

        // Create a time zone view and add it as a subview of self's contentView.
        CGRect tzvFrame = CGRectMake(0.0, 0.0, self.contentView.bounds.size.width, self.contentView.bounds.size.height);
        timeZoneView = [[TimeZoneView alloc] initWithFrame:tzvFrame];
        timeZoneView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
        [self.contentView addSubview:timeZoneView];
    }
    return self;
}
-(void)drawRect:(CGRect)rect {
    NSLog(@"Test 2");
}

- (void)setTimeZoneWrapper:(TimeZoneWrapper *)newTimeZoneWrapper {
    // Pass the time zone wrapper to the view
    timeZoneView.timeZoneWrapper = newTimeZoneWrapper;
}


- (void)redisplay {
    [timeZoneView setNeedsDisplay];
}


- (void)dealloc {
    [timeZoneView release];
    [super dealloc];
}


@end
于 2012-05-25T19:58:14.493 に答える