iPhone SDK UIView drawRect和方向更改
我已经写了这个代码。。。plotView是通过drawRect方法以编程方式绘制的。。。问题是当我更改设备方向时。。。所有视图的比例都不正确。。。自动调整大小的面具怎么了?我应该玩setNeedsDisplay或类似的游戏吗 提前谢谢iPhone SDK UIView drawRect和方向更改,iphone,sdk,drawrect,orientation-changes,setneedsdisplay,Iphone,Sdk,Drawrect,Orientation Changes,Setneedsdisplay,我已经写了这个代码。。。plotView是通过drawRect方法以编程方式绘制的。。。问题是当我更改设备方向时。。。所有视图的比例都不正确。。。自动调整大小的面具怎么了?我应该玩setNeedsDisplay或类似的游戏吗 提前谢谢 - (id)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { self.autoresizesSubviews = YES; self.a
- (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;
}也许这对你有帮助。