Skip to content

Commit 469a11f

Browse files
committed
Add manual selector check for creating UIGlassEffect
1 parent 9a173c1 commit 469a11f

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

Objective-C/TOCropViewController/Views/TOCropToolbar.m

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,19 @@ - (void)setup {
6161
if (@available(iOS 26.0, *)) {
6262
UIVisualEffect *effect = nil;
6363
#if !TARGET_OS_VISION
64-
UIGlassEffect *glassEffect = [UIGlassEffect effectWithStyle:UIGlassEffectStyleClear];
64+
// We've been getting reports that some devices have been crashing with the error message
65+
// that `effectWithStyle` was unrecognized. The ONLY way this seems to be possible
66+
// is if there are users out there using the beta versions of iOS 26.0 before this method
67+
// was introduced. Either way, we're going to need to manually confirm the selector exists
68+
// in order to fix these crashes.
69+
70+
UIGlassEffect *glassEffect = nil;
71+
SEL effectSelector = NSSelectorFromString(@"effectWithStyle:");
72+
if ([[UIGlassEffect class] respondsToSelector:effectSelector]) {
73+
glassEffect = [UIGlassEffect effectWithStyle:UIGlassEffectStyleClear];
74+
} else {
75+
glassEffect = [UIGlassEffect new];
76+
}
6577
glassEffect.interactive = YES;
6678
effect = glassEffect;
6779
#else

0 commit comments

Comments
 (0)