【问题标题】:Image picker status bar issue图像选择器状态栏问题
【发布时间】:2014-12-30 13:58:08
【问题描述】:

我在我的应用程序中使用状态栏,并以以下方式编写代码

我的项目包括标签栏控制器。因此,从库中选择图像后,我的状态栏正在改变它的位置。怎么解决?

请任何人帮忙解决这个问题,我浪费了很多时间。

if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7)
{
    self.window.clipsToBounds = YES;
    [[UIApplication sharedApplication] setStatusBarStyle: UIStatusBarStyleBlackOpaque];

    UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;
    if(orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight)
    {
        self.window.frame =  CGRectMake(0, 0,self.window.frame.size.width-20,self.window.frame.size.height);
        self.window.bounds = CGRectMake(0, 0, self.window.frame.size.width, self.window.frame.size.height);
    } else
    {
        self.window.frame =  CGRectMake(0,20,self.window.frame.size.width,self.window.frame.size.height);
        self.window.bounds = CGRectMake(0, 20, self.window.frame.size.width, self.window.frame.size.height);
    }
}

提前致谢。

【问题讨论】:

  • 你解决了吗?
  • 不,我试图从库中获取子视图(集合视图)中的图像,bcz presentmodel 导航干扰了我的应用程序。

标签: ios objective-c iphone xcode5 uiimagepickercontroller


【解决方案1】:

试试这个:

info.plist 文件中的密钥:

'View controller-based status bar appearance' and set to NO.

也在 appDelegate 中。

[application setStatusBarHidden:NO]; 
[application setStatusBarStyle:UIStatusBarStyleDefault];  // change style as per your requirement

【讨论】:

  • 一般来说你说的没错,但这里的情况不同,因为我使用带有导航栏的标签栏控制器,所以我需要更新标签栏和导航栏的框架。你能帮忙吗?
  • 然后你可以对 tabbarcontroller.view.frame 和每个 viewcontroller 做同样的事情 - viewcontroller.navigationcontroller.navigationbar.frame
【解决方案2】:

在 iOS7 及更高版本中,状态栏是透明的,因此实现这一点的最佳方法是制作一个基本控制器并从中扩展每个控制器,在基本控制器的viewDidLoad 中,只需创建该视图的单例对象(即黑色视图)与框架CGRectMake(0, 0, view.frame.size.width, view.frame.size.height) 与宽度自动调整掩码并将其添加为子视图。

【讨论】:

  • 是的,我在 Appdelagate.m 文件中编写了该代码,并使用其单例对象完成了您所说的操作,但我没有使用 Autolayout 概念。
  • 我不是在谈论自动布局我在谈论自动调整蒙版
  • @RakeshKumar 不要调整窗口大小,因为它是所有视图控制器的容器。
  • @Adeel Ur Rehman,感谢您带我了解新概念,我不知道这个概念,您有没有示例
  • @RakeshKumar 我在回答中进行了描述。如果您对此有任何困惑,请告诉我。
【解决方案3】:
(void)layoutSubviews {
    self.frame = CGRectMake(0, 0, 320, 64);
}

【讨论】:

  • 它是什么框架??(与视图或窗口或导航栏相关的框架)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-07-27
  • 2013-10-10
  • 1970-01-01
  • 2011-11-24
  • 2013-10-26
相关资源
最近更新 更多