【问题标题】:subclass uiwindow wont rotate to horizontal orientation子类 uiwindow 不会旋转到水平方向
【发布时间】:2012-03-06 11:03:00
【问题描述】:

我尝试继承 UIWindow 以覆盖状态栏以显示某些内容。但是当我的应用的方向 == UIInterfaceOrientationLandscapeLeft 或右时,此自定义窗口不会旋转。我该如何解决?

- (id)init {
  if (self = [super initWithFrame:CGRectMake(0, 0, 1024, 20)]) {
    self.windowLevel = UIWindowLevelStatusBar;

    UILabel *label = [[UILabel alloc] initWithFrame:self.frame];
    label.text = @"testing";
    label.backgroundColor = [UIColor blackColor];
    label.textColor = [UIColor whiteColor];
    label.textAlignment = UITextAlignmentCenter;
    [self addSubview:label];
    NSLog(@"label %@", label);
    [label release];

    [self makeKeyAndVisible];
  }

  return self;
}

【问题讨论】:

    标签: ios uiwindow


    【解决方案1】:

    我不认为 UIWindows 本身实际上是旋转的,而是您添加到窗口的 UIViewController 是处理旋转的那个。

    【讨论】:

    • 所以如果我想在应用旋转到横向时覆盖状态栏,我还能做什么?我试图修改窗口的变换,但它不会像我预期的那样工作,结果很奇怪。
    猜你喜欢
    • 1970-01-01
    • 2020-01-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-12-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多