preferredScreenEdgesDeferringSystemGestures obj-c Bitwise Op broken iOS16

Hi ! In discovery for why screen gestures were not being deferred when using correct function in an Objective-C/C++ UIViewController discovered this issue

Does not affect Swift

Tools Tested: Xcode 13/14 Beta iOS Target 12 +

Deferring gestures when using Objective-C UIViewController does not work using the normal bitwise op or the default Apple created bitwise op pipes ( | )

UIRectEdgeAll - Does not work:

- (UIRectEdge)preferredScreenEdgesDeferringSystemGestures {
    return UIRectEdgeAll;
}

UIRectEdge - using | - Does not work:

- (UIRectEdge)preferredScreenEdgesDeferringSystemGestures {

      UIRectEdge edges = UIRectEdgeNone;
      edges | UIRectEdgeTop;
      edges | UIRectEdgeBottom;
      edges | UIRectEdgeLeft;
      edges | UIRectEdgeRight;
      return edges;

}

Working solution for Objective-C use in UIViewController to use |= instead of |

- (UIRectEdge)preferredScreenEdgesDeferringSystemGestures {

      UIRectEdge edges = UIRectEdgeNone;
      edges |= UIRectEdgeTop;
      edges |= UIRectEdgeBottom;
      edges |= UIRectEdgeLeft;
      edges |= UIRectEdgeRight;
      return edges;

}

Issue originates in Objective-C code here for UIRectEdgeAll : UIKit/UIGeometry.h

typedef NS_OPTIONS(NSUInteger, UIRectEdge) {

    UIRectEdgeNone   = 0,

    UIRectEdgeTop    = 1 << 0,

    UIRectEdgeLeft   = 1 << 1,

    UIRectEdgeBottom = 1 << 2,

    UIRectEdgeRight  = 1 << 3,

    UIRectEdgeAll    = UIRectEdgeTop | UIRectEdgeLeft | UIRectEdgeBottom | UIRectEdgeRight

} API_AVAILABLE(ios(7.0));

Pipes used does not work: (use of |)

UIRectEdgeAll    = UIRectEdgeTop | UIRectEdgeLeft | UIRectEdgeBottom | UIRectEdgeRight

Solution (for Apple Engineers) :

Change bitwise pipe to instead of | to be |= (or equal to, += basically) in UIKit/UIGeometry.h

Replies

The declaration for UIRectEdgeAll in UIGeometry.h is correct. The bitwise or operator | is part of an expression that yields a value that is then used as the value of the UIRectEdgeAll enum.

To diagnose your issue, perhaps do this:

- (UIRectEdge)preferredScreenEdgesDeferringSystemGestures {
    UIRectEdge edges = UIRectEdgeAll;
    return edges; // Set breakpoint here
}

Set a breakpoint where indicated above, and examine the value of edges. It should have the value 0x0f hex, or 15 decimal.