iPhone SDK UIView drawRect и изменение ориентации - PullRequest
1 голос
/ 03 июля 2011

Я написал этот код ... plotView рисуется программно методом drawRect ... проблема в том, что я меняю ориентацию устройства ... все виды не масштабируются должным образом ... в чем проблема с автоматическим изменением размерамаска?я должен играть с setNeedsDisplay или аналогичным?

Заранее спасибо!

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

if (self) {

    self.autoresizesSubviews = YES;
    self.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;

    CGRect plotFrame = CGRectMake(0, 0, 1500, self.frame.size.height);

    // Initialization code.
    scrollView = [[UIScrollView alloc] initWithFrame:frame];
    scrollView.backgroundColor = [UIColor colorWithRed:240.0/255.0 green:240.0/255.0 blue:240.0/255.0 alpha:0.4];
    scrollView.scrollEnabled = YES;
    scrollView.autoresizesSubviews = YES;
    scrollView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
    scrollView.showsHorizontalScrollIndicator = YES;
    scrollView.showsVerticalScrollIndicator = NO;
    scrollView.alwaysBounceHorizontal = NO;
    scrollView.bounces = YES;
    scrollView.contentSize = CGSizeMake(plotFrame.size.width, plotFrame.size.height);
    scrollView.contentMode = UIViewContentModeScaleAspectFit;
    scrollView.delegate = self;
    //scrollView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
    [self addSubview:scrollView];

    plotView = [[PlotView alloc] initWithFrame:plotFrame];
    plotView.backgroundColor = [UIColor clearColor];
    plotView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
    [scrollView addSubview:plotView];
    [plotView release];

    [scrollView release];
}

return self;

}

...