• 3
  • 新人请关照

又拍直播云 错误:当使用iphone X时

* Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIStatusBar_Modern 0x106207ee0> valueForUndefinedKey:]: this class is not key value coding-compliant for the key foregroundView.'
* First throw call stack:
(0x182907d38 0x181b5c528 0x182907a00 0x1832af864 0x1831f5f70 0x1043d2af4 0x1043d1354 0x1043bf0e0 0x1043bf01c 0x105b9545c 0x105b9617c 0x1043befb4 0x10439fe34 0x105b9549c 0x105b9545c 0x105b9a050 0x1828aff20 0x1828adafc 0x1827ce2d8 0x184660f84 0x18bd8d034 0x102e46d18 0x1822f256c)
libc++abi.dylib: terminating with uncaught exception of type NSException

只出现在 iphone X

阅读 2.2k
评论
    5 个回答
    • 2.2k

    这个问题之前没遇到过, 不过Stack Overflow上已经有人回答了.

    NSArray *subviews = nil;
    id statusBar = [[UIApplication sharedApplication] valueForKey:@"statusBar"];
    if ([statusBar isKindOfClass:NSClassFromString(@"UIStatusBar_Modern")]) {
        subviews = [[[statusBar valueForKey:@"statusBar"] valueForKey:@"foregroundView"] subviews];
    } else {
        subviews = [[statusBar valueForKey:@"foregroundView"] subviews];
    }

    <UIStatusBar>this class is not key value coding-compliant for the key foregroundView.

      UPYUN 问答
      合作问答

      UPYUN 联合 SegmentFault 共同推出技术问答专区,为开发者们提供社区支持和帮助。 在这里,你将直接获得...