开发iPhone应用程序.
我有一个非常奇怪的问题,每隔一段时间,应用程序屏幕顶部的状态栏就会变成黑色.不像状态栏的黑色版本,而是像没有文字/图标的纯黑色矩形.这是非常罕见的,但通常似乎是在通过多任务或从锁定的设备(应用程序已在后台运行)返回应用程序后发生的.我已经看到它出现在3GS和iPhone4上.这是一个截图:

在尝试时我永远无法重现它,它似乎最终会在某个时刻发生(有时它会持续数天而不会发生).
一旦它确实发生,应用似乎继续正常运行,即使状态栏消失,除了我在应用程序中执行一个特定操作,这将导致一切都突然冻结(应用程序不会崩溃,但屏幕上的所有内容都是冻结的和非交互式的).在没有详细解释设计的情况下,导致其冻结的特定操作(在错误出现之后)在后台执行简单的上传到SQL数据库.一旦出现黑色状态栏,重置应用程序是解决问题的唯一方法.
有没有其他人经历过这个?我无法在任何地方找到解释类似行为的单一线程,这让我疯狂.
我有一个UIActionSheetiPad有三个选项:
当我触摸"照片库"选项时,我收到了崩溃和消息
UIStatusBarStyleBlackTranslucent在此设备上不可用.
我读了这篇文章,但没弄明白.
有人能帮我吗?
更新:
-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
if (buttonIndex == 0)
{
imgController = [[UIImagePickerController alloc] init];
imgController.allowsEditing = YES;
imgController.sourceType = UIImagePickerControllerSourceTypeCamera;
imgController.delegate=self;
[self presentModalViewController:imgController animated:YES];
}
else if (buttonIndex == 1)
{
imgController = [[UIImagePickerController alloc] init];
imgController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
imgController.delegate=self;
[self presentModalViewController:imgController animated:YES];
}
}
Run Code Online (Sandbox Code Playgroud)
我在最后一行崩溃了 [self presentModalViewController:imgController animated:YES];
在iOS 6.0中,由于默认情况下AppDelegate扩展了UIRepsonder而不是UIApplication,因此没有全局的sharedApplication对象.我错过了什么吗?我正在尝试使用以下设置状态栏方向,它似乎不再起作用.我在iOS 6.0模拟器上测试过它.我知道您可以从plist设置中设置状态栏色调颜色,但有人可以告诉我如何在iOS 6.0中以编程方式设置状态栏方向吗?
[[UIApplication sharedApplication] setStatusBarOrientation:UIDeviceOrientationPortrait animated:NO]
Run Code Online (Sandbox Code Playgroud) 我显然不明白如何在iOS 6中使用状态栏色调.我已经阅读了这个问题: 更改状态栏色调 但是实现建议的解决方案还没有解决问题.
我已在目标摘要窗格中配置了设置(样式和着色的默认设置),并将状态栏色调参数字典添加到我的info.plist,如WWDC 2012高级外观自定义中所述.
我的状态栏在启动时正确显示,但是一旦我导航到另一个视图控制器,状态栏就会变为黑色.
第二个视图控制器嵌入在自己的导航控制器中.这可能是问题的根源吗?
不管是什么原因,我希望有人可以提供一个解决方案,让我可以在整个申请过程中使我的状态栏保持一致.
如果有任何需要澄清的话,请告诉我,并提前感谢您的任何帮助.
我正在使用UIToolbar作为屏幕顶部的控件(没有导航控制器)工具栏具有我想要的外观,但状态栏完全清晰.我似乎无法模仿UIToolbar在其透明度方面的模糊.有没有人遇到过这个不涉及使用导航控制器的解决方案?


在io7中,视图顶部的状态栏是一场噩梦.我真的设法让它工作,所以它将被放置在视图上方.我这样做:
- (void)viewDidLoad
{
[super viewDidLoad];
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0) {
self.view.backgroundColor=[UIColor colorWithRed:(152/255.0) green:(204/255.0) blue:(51/255.0) alpha:1] ;
CGRect frame = self.topNav.frame; frame.origin.y = 20;
self.topNav.frame = frame;
}
....
}
Run Code Online (Sandbox Code Playgroud)
现在我的状态栏位于我的导航栏上方.
但是当谈到调用的UIImagePickerController东西是不同的时.上面的代码没有任何效果.我试着这样做:
- (void)showImagePickerForSourceType:(UIImagePickerControllerSourceType)sourceType
{
UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0) {
CGRect frame = self.imagePickerController.frame; frame.origin.y = 20;
self.imagePickerController.frame = frame;
}
imagePickerController.modalPresentationStyle = UIModalPresentationCurrentContext;
imagePickerController.sourceType = sourceType;
imagePickerController.delegate = self;
self.imagePickerController = imagePickerController;
self.imagePickerController.allowsEditing=YES;
....
} …Run Code Online (Sandbox Code Playgroud) 首先,我的应用程序的设置:
大多数应用程序的视图控制器都存在于您的标准导航控制器层次结构中,但我还在主应用程序窗口上有第二个窗口,它主持一个视图控制器(NotificationVC).如果NotificationVC正在显示通知,它将更改状态栏样式以与通知形成对比,但否则它会将样式推迟到主窗口的根视图控制器.
我的问题是主窗口中的更改通常会触发状态栏外观更新(推送,弹出或呈现视图控制器或调用-[UIViewController setNeedsStatusBarAppearanceUpdate])无效.
以下是相关代码NotificationVC:
@implementation NotificationVC
- (UIStatusBarStyle)preferredStatusBarStyle
{
if (self.isShowingNotification)
{
if (self.notificationView.hasDarkBackground)
{
return UIStatusBarStyleLightContent;
}
else
{
return UIStatusBarStyleDefault;
}
}
else
{
return [[UIApplication sharedApplication].delegate window].rootViewController.preferredStatusBarStyle;
}
}
@end
Run Code Online (Sandbox Code Playgroud)
如何让状态栏从主窗口中的一个视图控制器更新?
注意:手动设置状态栏外观(-[UIApplication setStatusBarStyle:])不适用于此应用程序.
我正在尝试更改状态栏样式 UISplitViewController
我曾经这样做过 UINavigationBar
UINavigationBar.appearance().barStyle = UIBarStyle.Black
但是UISplitViewController没有appearance财产
无论如何改变那种风格?
由于UIApplication.shared.setStatusBarStyle(.default, animated: true)从IOS9弃用是有可能改变的状态栏风格的动画上push?我在文档中找不到任何描述.
我有一个导航控制器,我用一些颜色着色我的导航栏,我希望状态栏(显示载体,wifi符号等)使用相同的颜色.
所以Info.plist,我已经开始View controller-based status bar appearance equal了NO.在Target > Deployment Info我设置Status Bar Style > Light:
我可以看到状态栏现在确实使用"浅色"样式,因为文本是浅/白色.但状态栏背景仍然与导航栏不同,如下所示.我怎么能纠正这个?