self.window不能在视图控制器内工作(self.window not working inside view controller)

编程入门 行业动态 更新时间:2024-10-28 09:22:24
self.window不能在视图控制器内工作(self.window not working inside view controller)

对于iOS 7,我有状态栏问题。 为此,我通过在Appdelegate中使用下面的代码解决了这个问题

if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7) { [[UIApplication sharedApplication] setStatusBarStyle: UIStatusBarStyleLightContent]; self.window.clipsToBounds =YES; self.window.frame = CGRectMake(0,20,self.window.frame.size.width,self.window.frame.size.height-20); self.window.bounds = CGRectMake(0,0, self.window.frame.size.width, self.window.frame.size.height); }

所有工作都很完美。

只有在拍照时出现问题。

当我打开相机或照片库时,我仍然可以看到状态栏,因此我看到了一半的导航标题,如下所示。

任何想法我怎么能克服这个错误?

问题是:

照片库/相机像上面的图像

如果我点击取消,我的视图会自动移动20px。

For iOS 7, I had status bar problem. For that I solved it by using below code in Appdelegate

if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7) { [[UIApplication sharedApplication] setStatusBarStyle: UIStatusBarStyleLightContent]; self.window.clipsToBounds =YES; self.window.frame = CGRectMake(0,20,self.window.frame.size.width,self.window.frame.size.height-20); self.window.bounds = CGRectMake(0,0, self.window.frame.size.width, self.window.frame.size.height); }

All is working perfectly.

Only it gives problem while taking photo.

When I open camera or photo gallery, I still see status bar and because of that I see half of the navigation title as shown below.

Any idea how can I overcome this error?

The problems are :

Photo Gallery/ Camera comes like above image

If I click cancel, my view is shifted 20px up automatically.

最满意答案

我面临这个问题与我的项目之一。 我们甚至没有许多类的xib。 所以我只能在委托函数中重新设置框架。

[self.navigationController dismissViewControllerAnimated:YES completion:^{ [self.navigationController.view setFrame:CGRectMake(self.navigationController.view.frame.origin.x, [UIApplication sharedApplication].statusBarFrame.size.height, self.navigationController.view.frame.size.width, [[UIScreen mainScreen] bounds].size.height-[UIApplication sharedApplication].statusBarFrame.size.height)]; }];

我把这个放在照片/照相机纠察,邮件选取器的完成/取消委托方法中。

I faced this problem wih one of my project. We didn't even have the xib for many classes. So all I could do is reset the frame once again in the delegate functions.

[self.navigationController dismissViewControllerAnimated:YES completion:^{ [self.navigationController.view setFrame:CGRectMake(self.navigationController.view.frame.origin.x, [UIApplication sharedApplication].statusBarFrame.size.height, self.navigationController.view.frame.size.width, [[UIScreen mainScreen] bounds].size.height-[UIApplication sharedApplication].statusBarFrame.size.height)]; }];

I put this in the finish/cancel delegate methods of photo/camera picket, mail picker.

更多推荐

本文发布于:2023-07-30 12:28:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1337864.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:能在   视图   控制器   工作   window

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!