【发布时间】:2016-06-02 08:07:23
【问题描述】:
我有一个 UIView,
UIView *topBarView
我正在决定大小,即 topBarView 的宽度和高度
CGSizeMake(self.view.bounds.size.width, self.view.bounds.size.height*.05);
现在我将 topBarView 的框架设置为
topBarView.frame = (CGRect){0, 0,topBarSize};
我是我的视图控制器,我已经为旋转设置了这个条件
- (BOOL)shouldAutorotate
{
return YES;
}
-(UIInterfaceOrientationMask)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
}
当我的视图控制器以纵向模式打开时,一切都很好,正如预期的那样,topBarView 被放置在顶部
但是当我的视图以横向左模式打开时,topBarView 而不是在横向模式中位于顶部,而是在屏幕的左侧,即与纵向模式相同的帧
我该如何解决这个问题?
【问题讨论】:
-
您在 viewDidLoad 或 viewWillAppear 中设置 topBarview 框架的位置??
-
我已经在 viedDidLoad 中设置了
-
你能在 viewDidAppear() 方法里面试试吗。如果问题仍然存在,请告诉我
标签: ios objective-c uiview cgrect