【发布时间】:2011-07-08 08:02:04
【问题描述】:
我在 InterfaceBuilder 的 UIViewController 中有一个自定义 UIView videoView。
当我加载它时,它看起来不错,但是当我把它转为“从纵向到横向”时,它并没有按照坐标告诉它。然后当我把它转回来时,它又错了。
我有以下代码:
-(void)viewWillAppear:(BOOL)animated
{
[self processRotation:self.interfaceOrientation];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return YES;
}
-(void)processRotation:(UIInterfaceOrientation)_interfaceOrientation
{
if (_interfaceOrientation == UIInterfaceOrientationLandscapeLeft || _interfaceOrientation == UIInterfaceOrientationLandscapeRight)
{
videoView.frame = CGRectMake(20.0f, 77.0f, 984.0f, 595.0f);
}
else if (_interfaceOrientation == UIInterfaceOrientationPortrait || _interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)
{
videoView.frame = CGRectMake(20.0f, 297.0f, 728.0f, 453.0f);
}
}
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
[self processRotation:toInterfaceOrientation];
}
【问题讨论】:
-
嗨,daidai,我可以推荐我最近的一篇文章来帮助您解决问题:stackoverflow.com/questions/6580052/…
标签: iphone objective-c uiview uiviewcontroller uiinterfaceorientation