相关疑难解决方法(0)

[UIScreen mainScreen] .bounds.size在iOS8中是否依赖于方向?

我在iOS 7和iOS 8中运行了以下代码:

UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
BOOL landscape = (orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight);
NSLog(@"Currently landscape: %@, width: %.2f, height: %.2f", 
      (landscape ? @"Yes" : @"No"), 
      [[UIScreen mainScreen] bounds].size.width, 
      [[UIScreen mainScreen] bounds].size.height);
Run Code Online (Sandbox Code Playgroud)

以下是iOS 8的结果:

Currently landscape: No, width: 320.00, height: 568.00
Currently landscape: Yes, width: 568.00, height: 320.00
Run Code Online (Sandbox Code Playgroud)

与iOS 7中的结果相比:

Currently landscape: No, width: 320.00, height: 568.00
Currently landscape: Yes, width: 320.00, height: 568.00
Run Code Online (Sandbox Code Playgroud)

是否有任何文件指定此更改?或者它是iOS 8 API中的临时错误?

orientation uiinterfaceorientation ios uiscreen ios8

184
推荐指数
8
解决办法
8万
查看次数

_UIApplicationHandleEventFromQueueEvent中的意外nil窗口

我的一个旧应用程序不适用于iOS8.当我启动应用程序并尝试在任何地方点击屏幕时,我在控制台中收到此消息:

unexpected nil window in _UIApplicationHandleEventFromQueueEvent, 
_windowServerHitTestWindow: <UIWindow: 0x7fe4d3e52660; frame = (0 0; 320 568); 
opaque = NO; autoresize = RM+BM; gestureRecognizers = <NSArray: 0x7fe4d3e2c450>; 
layer = <UIWindowLayer: 0x7fe4d3e86a10>>
Run Code Online (Sandbox Code Playgroud)

我正在使用旧式MainWindow.xib.在MainWindow.xib中是我的Window对象,以及UINavigationController,它也在其中定义了第一个View Controller.下图显示了连接到App Delegate的Outlets.

下面屏幕截图中的白色"视图"是UIWindow.右边的视图是UINavigationController(隐藏导航栏),其中定义了第一个ViewController.

在此输入图像描述

如何在不使用新项目从头开始重新创建整个应用程序的情况下解决此问题?

编辑:我刚刚发现有一个TINY条带,其中我的按钮实际上会收到他们的点击/点击.

我也注意到我的self.view.window是零.我如何确保设置?

在此输入图像描述

uiwindow hittest ios8

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

应该在iOS 8中进行动作

我在UIViewController shouldAutorotate方法上发现了7.1和8之间的小行为变化.Apple View Controller编程指南指出在执行任何自动旋转之前调用此方法.

但是我注意到,当我只是禁用shouldAutorotate(返回NO)时,该方法在Portrait - > Landscape rotation上调用,但不在下面的Landscape - > Portrait rotation上调用.同样应该始终按照我的理解调用该方法.在iOS 8上运行时会发生这种情况,但在iOS 7.1上则不会.

这似乎与iOS8中调用堆栈中的新方法有关:

[UIWindow shouldAutorotateToInterfaceOrientation:checkForDismissal:isRotationDisabled]

我找不到有关此方法及其行为的任何描述,任何想法,我可以找到有关此内部方法的更多信息

重现这个的简单步骤:

  1. 在Xcode中创建一个新的单视图应用程序项目
  2. 更新您ViewController.m的实施shouldAutorotate

    - (BOOL)shouldAutorotate
    {
        UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];
        NSLog(@"%s orientation is %@", __PRETTY_FUNCTION__, [self stringFromDeviceOrientation:orientation]);
        // Disable autorotation of the interface.
        return NO;
    }
    
    - (NSString *) stringFromDeviceOrientation:(UIDeviceOrientation)uido
    {
        NSString *orientation = @"UIDeviceOrientationUnknown";
        switch (uido) {
            case UIDeviceOrientationPortrait:
                orientation = @"Portrait";
                break;
            case UIDeviceOrientationPortraitUpsideDown:
                orientation = …
    Run Code Online (Sandbox Code Playgroud)

iphone objective-c ios

8
推荐指数
1
解决办法
1万
查看次数