简体   繁体   English

iPhone视图被切断

[英]Iphone view got cut off

My landscape subview is being cut off by the previous view, why is it like that? 我的风景子视图已被上一个视图截断,为什么会这样?

Cut off as in the previous view is at the bottom part around 1/3 quarter of the screen even when the new subview is added. 即使添加了新的子视图,也像上一个视图一样在屏幕的1/3处的底部切除。 Something like this > http://i41.photobucket.com/albums/e253/welzenn99/123.png 像这样的东西> http://i41.photobucket.com/albums/e253/welzenn99/123.png

you need to set that view's frame in 您需要在其中设置该视图的框架

  - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {

OR in

 - (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration;

in the method where you tell the subview to come out ([self.view addSubview:someView.view];) add 在告诉子视图出来的方法中[[self.view addSubview:someView.view];)添加

UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];
if ((orientation == UIDeviceOrientationLandscapeLeft || orientation == UIDeviceOrientationLandscapeRight)) {
    //rotate to landscape
    someView.view.frame = CGRectMake(0,0,480,320);
}
else if (orientation == UIDeviceOrientationPortrait) {
    //rotate to portrait 
    isomeView.view.frame = CGRectMake(0,0,320,480);
}

worked for me. 为我工作。 good luck 祝好运

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM