首页 文章

通过programaticaly以横向模式添加视图

提问于
浏览
0

我有一个横向模式的应用程序,现在我在appdelegate中添加一个视图,但它在纵向模式下显示 . 旋转90度

下面是我在appdelegate中添加的代码

-(void)addProcessingView{
    UIView*container = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 500, 100)] autorelease];
    container.backgroundColor = [UIColor grayColor];
    UILabel *label = [[[UILabel alloc] initWithFrame:CGRectMake(100, 0, 400, 100)] autorelease];

  [container addSubview:label];
   UIActivityIndicatorView *active = [[[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(0, 0, 100 , 100)] autorelease];
  [container addSubview:active];
  container.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin;
  [self.window addSubview:container];
  container.center = self.window.center;
}

见图

enter image description here

1 回答

  • 0

    我认为你必须改变视图的帧大小 . 将以下行替换为您的代码 . 它将解决您的问题 .

    UIView*container = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 500)] autorelease];
    

相关问题