Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ADREQ-4301] allow an interstitial to NOT auto-translate masks #370

Merged
merged 2 commits into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Examples/NYTPhotoViewer.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,9 @@
11BA4B0B1C8913330007EC46 /* Frameworks */,
9EBFA0C5928F2148DEB75556 /* Pods */,
);
indentWidth = 4;
sourceTree = "<group>";
tabWidth = 4;
};
111084071C875B5000699670 /* Products */ = {
isa = PBXGroup;
Expand Down
18 changes: 15 additions & 3 deletions NYTPhotoViewer/NYTInterstitialViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ @interface NYTInterstitialViewController ()
@property (nonatomic, nullable) id <NYTPhoto> photo;
@property (nonatomic, nullable) UIView *interstitialView;
@property (nonatomic) NSUInteger photoViewItemIndex;
@property (nonatomic, nullable) NSArray<NSLayoutConstraint *> *constraints;
mr-fixit marked this conversation as resolved.
Show resolved Hide resolved

- (instancetype)initWithCoder:(NSCoder *)aDecoder NS_DESIGNATED_INITIALIZER;

Expand All @@ -37,17 +38,28 @@ - (instancetype)initWithCoder:(NSCoder *)aDecoder {
return self;
}

- (void)prepareLayout {
if (self.interstitialView.translatesAutoresizingMaskIntoConstraints) {
self.interstitialView.center = CGPointMake(CGRectGetMidX(self.view.bounds), CGRectGetMidY(self.view.bounds));
} else if (self.constraints == NULL) {
mr-fixit marked this conversation as resolved.
Show resolved Hide resolved
self.constraints = @[
[self.interstitialView.centerXAnchor constraintEqualToAnchor:self.view.centerXAnchor],
[self.interstitialView.centerYAnchor constraintEqualToAnchor:self.view.centerYAnchor],
];
[NSLayoutConstraint activateConstraints:self.constraints];
}
}

- (void)viewDidLoad {
[super viewDidLoad];

[self.view addSubview:self.interstitialView];
self.interstitialView.center = CGPointMake(CGRectGetMidX(self.view.bounds), CGRectGetMidY(self.view.bounds));
[self prepareLayout];
}

- (void)viewWillLayoutSubviews {
[super viewWillLayoutSubviews];

self.interstitialView.center = CGPointMake(CGRectGetMidX(self.view.bounds), CGRectGetMidY(self.view.bounds));
[self prepareLayout];
mr-fixit marked this conversation as resolved.
Show resolved Hide resolved
}

- (BOOL)prefersHomeIndicatorAutoHidden {
Expand Down