Skip to content

Commit

Permalink
Fix access to UIWindow when delegate doesn't implement that property
Browse files Browse the repository at this point in the history
  • Loading branch information
Supereg committed Mar 5, 2024
1 parent 15f06cf commit 3829e9b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,12 @@ - (void)resetAfterDelay:(NSTimeInterval)delay completion:(nullable void (^)(void
}

-(void)resizeConstraints {
ORKScreenType screenType = ORKGetVerticalScreenTypeForWindow([[[UIApplication sharedApplication] delegate] window]);
ORKScreenType screenType;
if ([[UIApplication sharedApplication].delegate respondsToSelector:@selector(window)]) {
screenType = ORKGetVerticalScreenTypeForWindow([[[UIApplication sharedApplication] delegate] window]);
} else {
screenType = ORKGetVerticalScreenTypeForWindow(NULL);
}
if (screenType == ORKScreenTypeiPhone5 ) {
NormalizeButtonSize = 70.0;
BackgroundViewSpaceMultiplier = 1.75;
Expand Down
18 changes: 14 additions & 4 deletions ResearchKit/ActiveTasks/ORKStroopContentView.m
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,13 @@ - (instancetype)initWithFrame:(CGRect)frame {
[_colorLabel setFont:[UIFont systemFontOfSize:60]];
[_colorLabel setAdjustsFontSizeToFitWidth:YES];

ORKScreenType screenType = ORKGetVerticalScreenTypeForWindow([[[UIApplication sharedApplication] delegate] window]);

ORKScreenType screenType;
if ([[UIApplication sharedApplication].delegate respondsToSelector:@selector(window)]) {
screenType = ORKGetVerticalScreenTypeForWindow([[[UIApplication sharedApplication] delegate] window]);
} else {
screenType = ORKGetVerticalScreenTypeForWindow(NULL);
}

if (screenType == ORKScreenTypeiPhone5 ) {
labelWidth = 200.0;
labelHeight = 200.0;
Expand Down Expand Up @@ -145,8 +150,13 @@ -(void)setupGridButtons {

_buttonStackView.axis = UILayoutConstraintAxisVertical;

ORKScreenType screenType = ORKGetVerticalScreenTypeForWindow([[[UIApplication sharedApplication] delegate] window]);

ORKScreenType screenType;
if ([[UIApplication sharedApplication].delegate respondsToSelector:@selector(window)]) {
screenType = ORKGetVerticalScreenTypeForWindow([[[UIApplication sharedApplication] delegate] window]);
} else {
screenType = ORKGetVerticalScreenTypeForWindow(NULL);
}

if (screenType == ORKScreenTypeiPhone6) {
minimumButtonHeight = 150.0;
} else if (screenType == ORKScreenTypeiPhone5 ) {
Expand Down

0 comments on commit 3829e9b

Please sign in to comment.