关闭

iPhone 代码实现横向 纵向 转换

789人阅读 评论(0) 收藏 举报

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation{


}

 

[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeLeft];

self.view.transform = transform;

这里要把view 旋转.

配合一起使用

 

[原文链接:http://blog.sina.com.cn/s/blog_5730da6b0100h6z9.html]

//纵向转横向,带电池状态栏,由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;
}

 

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:15407次
    • 积分:201
    • 等级:
    • 排名:千里之外
    • 原创:2篇
    • 转载:15篇
    • 译文:0篇
    • 评论:2条
    文章存档
    最新评论