简体   繁体   English

CGRectMake在横向模式下不能完美运行吗?

[英]CGRectMake did not work perfectly in landscape mode?

when I draw a UIView in landscape mode of ipad , it gives wrong width and wrong height,i have mentioned as follows 当我在ipad的横向模式下绘制UIView时,它给出了错误的宽度和错误的高度,我提到如下

 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
  return (interfaceOrientation==UIInterfaceOrientationLandscapeRight);
}

rightView.view.frame = CGRectMake(598, 700, 60, 171);

but width is very high,height is very low…any help please? 但是宽度非常高,高度非常低……有什么帮助吗?

When in landscape mode, as the frame is in the coordinates system of its parent view and the parent view has a CGAffineTransform applied (to apply the interface orientation), with and height are inverted. 在横向模式下,由于框架位于其父视图的坐标系中,并且父视图已应用CGAffineTransform(以应用界面方向),因此高度反转。

See this other question that also deals with related issues 请参阅另一个也处理相关问题的问题

YOu may set frame like. 您可能会设置框架。 it will give you a require result. 它会给你一个需要的结果。

    CGRectMake(self.view.size.width-426 ,self.view.size.height-100 , self.view.size.width-366, self.view.size.height-497);

只需在rightView.view.frame = CGRectMake(598,700,171,60)行下面编写;

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

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