Skip to content

Commit 91a2953

Browse files
bryanoltmanmaterial-automation
authored andcommitted
Add isPointerInteractionEnabled availability check.
There are still some iOS 13.4 betas floating around that had not yet introduced this API. This change should prevent those users from crashing when attempting to get/set this value. PiperOrigin-RevId: 326248791
1 parent ad2b161 commit 91a2953

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

components/Buttons/src/MDCFloatingButton+Animation.m

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
// limitations under the License.
1414

1515
#import "MDCFloatingButton+Animation.h"
16+
#import "MDCFloatingButton.h"
1617

1718
#if TARGET_IPHONE_SIMULATOR
1819
float UIAnimationDragCoefficient(void); // Private API for simulator animation speed
@@ -96,8 +97,10 @@ - (void)expand:(BOOL)animated completion:(void (^_Nullable)(void))completion {
9697
#ifdef __IPHONE_13_4
9798
BOOL wasPointerInteractionEnabled = NO;
9899
if (@available(iOS 13.4, *)) {
99-
wasPointerInteractionEnabled = self.pointerInteractionEnabled;
100-
self.pointerInteractionEnabled = NO;
100+
if ([self respondsToSelector:@selector(isPointerInteractionEnabled)]) {
101+
wasPointerInteractionEnabled = self.pointerInteractionEnabled;
102+
self.pointerInteractionEnabled = NO;
103+
}
101104
}
102105
#endif
103106
void (^expandActions)(void) = ^{
@@ -111,7 +114,9 @@ - (void)expand:(BOOL)animated completion:(void (^_Nullable)(void))completion {
111114
[self.imageView.layer removeAnimationForKey:kMDCFloatingButtonTransformKey];
112115
#ifdef __IPHONE_13_4
113116
if (@available(iOS 13.4, *)) {
114-
self.pointerInteractionEnabled = wasPointerInteractionEnabled;
117+
if ([self respondsToSelector:@selector(isPointerInteractionEnabled)]) {
118+
self.pointerInteractionEnabled = wasPointerInteractionEnabled;
119+
}
115120
}
116121
#endif
117122
if (completion) {
@@ -188,8 +193,10 @@ - (void)collapse:(BOOL)animated completion:(void (^_Nullable)(void))completion {
188193
#ifdef __IPHONE_13_4
189194
BOOL wasPointerInteractionEnabled = NO;
190195
if (@available(iOS 13.4, *)) {
191-
wasPointerInteractionEnabled = self.pointerInteractionEnabled;
192-
self.pointerInteractionEnabled = NO;
196+
if ([self respondsToSelector:@selector(isPointerInteractionEnabled)]) {
197+
wasPointerInteractionEnabled = self.pointerInteractionEnabled;
198+
self.pointerInteractionEnabled = NO;
199+
}
193200
}
194201
#endif
195202

@@ -204,7 +211,9 @@ - (void)collapse:(BOOL)animated completion:(void (^_Nullable)(void))completion {
204211
[self.imageView.layer removeAnimationForKey:kMDCFloatingButtonTransformKey];
205212
#ifdef __IPHONE_13_4
206213
if (@available(iOS 13.4, *)) {
207-
self.pointerInteractionEnabled = wasPointerInteractionEnabled;
214+
if ([self respondsToSelector:@selector(isPointerInteractionEnabled)]) {
215+
self.pointerInteractionEnabled = wasPointerInteractionEnabled;
216+
}
208217
}
209218
#endif
210219
if (completion) {

components/Dialogs/src/private/MDCAlertActionManager.m

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
// limitations under the License.
1414

1515
#import "MDCAlertActionManager.h"
16+
#import "MaterialButtons.h"
1617

1718
@interface MDCAlertActionManager ()
1819

@@ -93,7 +94,9 @@ - (MDCButton *)makeButtonForAction:(MDCAlertAction *)action
9394
button.accessibilityIdentifier = action.accessibilityIdentifier;
9495
#ifdef __IPHONE_13_4
9596
if (@available(iOS 13.4, *)) {
96-
button.pointerInteractionEnabled = YES;
97+
if ([self respondsToSelector:@selector(isPointerInteractionEnabled)]) {
98+
button.pointerInteractionEnabled = YES;
99+
}
97100
}
98101
#endif
99102
[button addTarget:target action:selector forControlEvents:UIControlEventTouchUpInside];

0 commit comments

Comments
 (0)