1

I've wrote this code... plotView is drawn programmatically by drawRect method... the problem is when I change the device orientation... all the views are not scaled properly... what's the matter with the autoresizing mask? should I play with setNeedsDisplay or similar?

Thanks in advance!

- (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;

}

Progeny
  • 672
  • 1
  • 11
  • 25
  • Maybe this [answer](http://stackoverflow.com/questions/2526162/iphone-sdk-how-to-trigger-drawrect-on-uiview-subclass-after-orientation-change) helps you. – Reinhold Feb 10 '12 at 09:39

0 Answers0