UIview显示半屏IOS7

时间:2014-04-24 12:07:12

标签: ios uiview

嗨,在我的应用程序中,我有弹出视图。我已经制作了透明的背景,并且我在它上面使用了UIView,但在模拟器中它只在屏幕上显示了一半。如下图所示。

这是我的UIviewcontroller图像

enter image description here

在模拟器中它显示如下。

enter image description here

3 个答案:

答案 0 :(得分:0)

尝试将您的模拟器更改为3.5英寸,因为从我看到的内容中,您无法在视图中添加自动布局以支持4英寸。

详细了解Autolayout

答案 1 :(得分:0)

您可以使用以下代码:

-(void)viewDidLoad
{
  backgroundButton = [[UIButton alloc] initWithFrame:CGRectMake(0,0,self.view.frame.size.width,self.view.frame.size.height)];  //Background button to handle tap outside popup view

  [backgroundButton addTarget:self action:@selector(tapDetected) forControlEvents:UIControlEventTouchUpInside];
}

-(void)tapDetected /* When user tap outside popup view so as to dismiss the view*/
{
  [backgroundButton removeFromSuperview];
  [tempView removeFromSuperview];
}

-(void)buttonClicked:(UIButton *)sender /*To create and open popup view */
{
  [self.view addSubview:backgroundButton];

  tempView = [[UIView alloc] initWithFrame:CGRectMake(15, 100, 300, 300)]; //PopUp View
  [tempView setBackgroundColor:[UIColor redColor]]; 

  [backgroundButton addSubview:tempView];

  [tempView setAlpha:1];
}

答案 2 :(得分:0)

很可能注册控件(UILabel和UItextviews)在self.view上添加,而不是在半屏尺寸的视图上。