我已经编写了这段代码... 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;
}