setStatusBarOrientation 方法redis set 过期时间了,有什么替换方法吗

iphone - setStatusBarOrientation issue - Stack Overflow
to customize your list.
Join the Stack Overflow Community
Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.
J it only takes a minute:
I have a navigation controller app. And first I push FirstViewController (support Portrait orientation) and then SecondViewController (supports all orientations). When I'm in landscape mode of SecondViewController and press back button, FirstViewController appears in landscape mode. That's why I manually rotate the navigation view, but when I want to set setStatusBarOrientation to Portrait (First view controller should appears only in portrait mode), the orientation of view controller is still landscape, and even if rotate the device to portrait mode, the orientation stay landscape
.Here is my code of FirstViewController:
- (void)viewWillAppear:(BOOL)animated
if (UIInterfaceOrientationIsLandscape(self.interfaceOrientation))
if (self.interfaceOrientation == UIInterfaceOrientationLandscapeLeft) {
prevInterfaceOrientation = UIInterfaceOrientationLandscapeL
self.navigationController.view.transform = CGAffineTransformI
self.navigationController.view.transform =
CGAffineTransformMakeRotation(degreesToRadians(90));
else if (self.interfaceOrientation ==
UIInterfaceOrientationLandscapeRight) {
prevInterfaceOrientation = UIInterfaceOrientationLandscapeR
self.navigationController.view.transform = CGAffineTransformI
self.navigationController.view.transform =
CGAffineTransformMakeRotation(degreesToRadians(-90));
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait animated:NO];
[self.tableViewDetail reloadData];
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
return (interfaceOrientation == UIInterfaceOrientationPortrait);
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
if (toInterfaceOrientation == UIInterfaceOrientationPortrait)
if (prevInterfaceOrientation == UIInterfaceOrientationLandscapeLeft) {
self.navigationController.view.transform = CGAffineTransformI
else if (prevInterfaceOrientation ==
UIInterfaceOrientationLandscapeRight) {
self.navigationController.view.transform = CGAffineTransformI
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait];
[self.tableViewDetail reloadData];
I even tried to use:
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
if (UIInterfaceOrientationIsLandscape(prevInterfaceOrientation))
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait];
self.interfaceOrientation still stays landscape, when I rotate to portrait.
But I really need to rotate the view to portrait mode manually to allow users to see,that FirstViewController suppors only portrait orientation.
I have the option to put the SecondViewController's view on MainWindow (like modal window), but I don't like this idea, because if apple has setStatusBarOrientation method, it seems to me, that it has to be right solve of this issue.
1,31031943
I would get rid of the transformations, and use
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait animated:animated];
This in combination with the forced redrawing of the view stack will get it done.
This can be done by adding the following to viewDidAppear to the first controller (it doesn't work in viewWillApear).
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
UIWindow *window = [[UIApplication sharedApplication] keyWindow];
if ([window.subviews count] & 0) {
UIView *view = [window.subviews objectAtIndex:0];
[view removeFromSuperview];
[window insertSubview:view atIndex:0];
DLog(@"NO view to force rotate?");
Unfortunately, the transition animation is not very clean when you do this, so I would recommend taking a snapshot of the portrait screen, overlay this over your view, and then fade it out with a separate animation.
Steven Veltema's answer didn't work for me.
I had one view controller where all orientations where allowed, and the rest only supported portrait. When i had the first view controller in landscape and navigated to another view controller, the orientation didn't refresh as you are experiencing.
I found another trick to reload the views i correct orientation. Just add a modal view controller you don't even see it. Add this in all other views:
- (void)viewDidAppear:(BOOL)animated
UIInterfaceOrientation interfaceOrientation = [[UIApplication sharedApplication] statusBarOrientation];
if(UIInterfaceOrientationIsLandscape(interfaceOrientation)){
UIViewController * viewController = [[UIViewController alloc] init];
[self presentModalViewController:viewController animated:NO];
[viewController dismissModalViewControllerAnimated:NO];
[super viewDidAppear:animated];
2,30222651
Another quick solution is
Click on your project in the left side bar.
In General settings, choose "Hide during application launch" option.
Your Answer
Sign up or
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Post as a guest
By posting your answer, you agree to the
Not the answer you're looking for?
Browse other questions tagged
Stack Overflow works best with JavaScript enabled查看:2573|回复:1
助理工程师
ViewController1 用到了纵向,ViewController2 用到了横向。如果我用: [[UIApplication sharedApplication] setStatusBarOrientation: UIInterfaceOrientationPortrait];
复制代码我会被拒么?如果不能这么调用,我有其他的选择么?简单的旋转图像恐怕是不够的,因为我在正确的方向上用到了动作表单和报警提示。
助理工程师
不会,当可能用户体验不好~iphone - setStatusBarOrientation causing problems in iOS8 - Stack Overflow
to customize your list.
Join the Stack Overflow Community
Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.
J it only takes a minute:
I'm having real problems with my apps under iOS8. I've made a bunch of OpenGL based apps, which don't need the iOS to handle the orientation. It's all handled within the OpenGL section. But I do use setStatusBarOrientation to make sure any dialogs/keyboards etc that pop up line up with everything else. I'm creating my window and view programatically or in a xib, I've never needed to use a storyboard (in case thats relevant?)
It's all been perfect, til iOS 8 came along.
Now it seems that setStatusBarOrientation isn't behaving properly at all. It's either not changing anything, or it's rotating "something" that stops touches being recorded on half the screen. It's as if the window is being rotated within itself, but visually nothing changes, just the touches are effected.
It's hard to explain, and makes no sense.
But my question is: How do you set the status bar orientation in iOS8? And how do you do it without destroying everything else that works in previous iOS versions?
35.4k83776
Set iOS7.1 as your Base SDK, and it'll work fine on iOS8, without all these strange bugs.
found this
if ([UIViewController class]) // iOS8 has this class only
[[UIDevice currentDevice] setValue:[NSNumber numberWithInteger:UIDeviceOrientationPortrait] forKey:@"orientation"];
found here:
seems to work
Your Answer
Sign up or
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Post as a guest
By posting your answer, you agree to the
Not the answer you're looking for?
Browse other questions tagged
Stack Overflow works best with JavaScript enabled3000人阅读
个人经验(5)
ios7,碰到个需要手动调整状态栏方向的问题,于是调用了下面这段代码。//设置状态栏 横屏
[[UIApplication sharedApplication]setStatusBarOrientation:UIInterfaceOrientationLandscapeRight];
问题来了,死活就是没有效果。
经过一番寻找,发现是
UIviewController方法- (BOOL)shouldAutorotate 返回值为YES的时候是不生效的。
发现原因了,马上解决,成功?
NO,你太天真了。
立马发现了下个问题,覆写方法- (BOOL)shouldAutorotate,仍然未生效。
好吧,公布答案吧:由于UIViewController放置在Navigation中,而由于Navigation不人性化的设计,navigation的- (BOOL)shouldAutorotate是不会根据显示ViewController的- (BOOL)shouldAutorotate设置的值来改变的。
附上终极解决办法:将下面这段代码贴在AppDelegate.m的最后面,这个时候Navigation就会根据你显示的ViewController改变返回值了,然后你再去ViewController中覆写方法,返回NO,这时候,方法生效了!bingo!
@implementation UINavigationController (Rotation)
- (BOOL)shouldAutorotate
return [[self.viewControllers lastObject] shouldAutorotate];
- (NSUInteger)supportedInterfaceOrientations
return [[self.viewControllers lastObject] supportedInterfaceOrientations];
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
return [[self.viewControllers lastObject] preferredInterfaceOrientationForPresentation];
iOS7 如果在 info文件中,加上一列View controller-based status bar appearance
用下面的方法可以轻松控制
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:NO];
参考知识库
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:11508次
排名:千里之外
原创:19篇
(1)(1)(2)(8)(1)(6)(1)

我要回帖

更多关于 redis set 过期 的文章

 

随机推荐