分类: BSD
2011-01-14 16:47:04
因为iPhone屏幕太有限,所以不得不在有限的空间里尽量闪转腾挪以显示更丰富的内容,于是,有时候屏幕要根据需要在横向和纵向之间转换。而这种情况下的强制转换,是不能通过iPhone的加速器来实现的。
//纵向转横向,带电池状态栏,由320*460改为480*300
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeLeft];
- (id)initWithNibName:(NSString *)nibName bundle:(NSBundle *)nibBundle{
CGAffineTransform transform = CGAffineTransformMakeRotation(-3.14159/2);
self.view.transform = transform;
CGPoint center = self.view.window.center;
[self.view setCenter:CGPointMake(center.x+170, center.y+220)];
[super initWithNibName:nibName bundle:nibBundle];
self.chart.parent = self;
return self;
}
//横向转纵向,带电池状态栏,由480*300改为320*460
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait];
- (id)initWithNibName:(NSString *)nibName bundle:(NSBundle *)nibBundle{
CGAffineTransform transform = CGAffineTransformMakeRotation(3.14159/2);
self.view.transform = transform;
CGPoint center = self.view.window.center;
[self.view setCenter:CGPointMake(center.x+230, center.y+140)];
[super initWithNibName:nibName bundle:nibBundle];
return self;
}