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