相关疑难解决方法(0)

使用横向时UIWindow的大小错误

我有一个空的应用程序,没有涉及故事板或xib.我希望有一个隐藏的状态栏,只支持横向.同样,我不想仅在代码中进行这些更改,也不要触摸Info.plist.

问题

我创建了一个带控制器的UIWindow,它表示唯一支持的方向是landscape.在这种情况下,我的UIWindow是在纵向模式的维度中创建的,不会旋转.预期结果将是完全青色的屏幕.

UIWindow破了

这是我的代表:

#import "AppDelegate.h"
#import "AppViewController.h"

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
  self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
  self.window.backgroundColor = [UIColor cyanColor];
  self.window.rootViewController = [[AppViewController alloc] init];
  [self.window makeKeyAndVisible];
  return YES;
}

@end
Run Code Online (Sandbox Code Playgroud)

这是我的控制器:

#import "AppViewController.h"

@implementation AppViewController

- (BOOL)shouldAutorotate {
  return YES;
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
  return UIInterfaceOrientationLandscapeLeft;
}

- (BOOL)prefersStatusBarHidden {
  return YES;
}

- (NSUInteger)supportedInterfaceOrientations {
  return UIInterfaceOrientationMaskLandscape;
}

@end
Run Code Online (Sandbox Code Playgroud)

到目前为止我尝试过的

如果我在调用makeKeyAndVisible之后设置了rootViewController,那么一切似乎都起作用.

self.window.backgroundColor = [UIColor cyanColor];
[self.window makeKeyAndVisible];
self.window.rootViewController = [[AppViewController alloc] init]; …
Run Code Online (Sandbox Code Playgroud)

iphone landscape objective-c uiwindow ios

17
推荐指数
2
解决办法
2万
查看次数

_UIApplicationHandleEventFromQueueEvent,_windowServerHitTestWindow中的意外nil窗口

我试图在iPad上的iOS 8中设置边缘滑动手势但是获取和错误似乎是一个错误.

我有以下代码:

    UIScreenEdgePanGestureRecognizer *edgeRecognizer = [[UIScreenEdgePanGestureRecognizer alloc] initWithTarget:self action:@selector(handleRightEdgeSwipe:)];
edgeRecognizer.edges = UIRectEdgeRight;
[self.view addGestureRecognizer:edgeRecognizer];
Run Code Online (Sandbox Code Playgroud)

然后我处理手势:

-(void)handleRightEdgeSwipe:(UIGestureRecognizer*)sender
{
//slide in view code here
}
Run Code Online (Sandbox Code Playgroud)

问题是它不会每次都检测到右边缘滑动.有时它会多次检测到它.

无论是否检测到它在iPad上滑动右边缘时始终在控制台中显示以下信息:

2014-10-07 00:04:40.386 Office日志[1531:500896] _UIApplicationHandleEventFromQueueEvent中的意外nil窗口,_ windowowServerHitTestWindow :; layer =>

此消息的含义是什么?如何修复它以便始终检测到右边缘滑动?

objective-c ipad ios uipangesturerecognizer ios8

11
推荐指数
3
解决办法
2万
查看次数

这是iOS 8 Bug(轮换方向问题)吗?

从iOS 8开始,我的App运行得非常好,但是在测试这个应用程序时我发现了一个问题.它只发生在iPad上,只有我在横向模式下启动应用程序.如果它在Portrait中启动,一切都是正确的(没有旋转问题).如果我旋转设备(模拟器或真实设备),视图将旋转出屏幕,只显示实际视图的剪切,其余为黑色.

在此输入图像描述

在此输入图像描述

其他人确实注意到这样的错误?我该如何解决?

rotation ios

6
推荐指数
1
解决办法
3277
查看次数