Skip to content

Commit

Permalink
Bug/max_mrec_behind_ads (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
MugiwaraxD authored Jul 15, 2020
1 parent 3c3c4c1 commit 85ea9c9
Show file tree
Hide file tree
Showing 6 changed files with 173 additions and 117 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,39 +31,70 @@ - (void)viewDidAppear:(BOOL)animated
self.adView.adDisplayDelegate = self;
self.adView.adEventDelegate = self;
self.adView.translatesAutoresizingMaskIntoConstraints = false;
self.callbackTableView.translatesAutoresizingMaskIntoConstraints = false;

// Call loadNextAd() to start showing ads
[self.adView loadNextAd];

[self.view addSubview: self.adView];
[self.view addConstraints: @[[NSLayoutConstraint constraintWithItem: self.adView
attribute: NSLayoutAttributeCenterX
relatedBy: NSLayoutRelationEqual
toItem: self.view
attribute: NSLayoutAttributeCenterX
multiplier: 1.0
constant: 0.0],
[NSLayoutConstraint constraintWithItem: self.adView
attribute: NSLayoutAttributeCenterY
relatedBy: NSLayoutRelationEqual
toItem: self.view
attribute: NSLayoutAttributeCenterY
multiplier: 1.0
constant: 0.0],
[NSLayoutConstraint constraintWithItem: self.adView
attribute: NSLayoutAttributeHeight
relatedBy: NSLayoutRelationEqual
toItem: nil
attribute: NSLayoutAttributeNotAnAttribute
multiplier: 1.0
constant: kMRECHeight],
[NSLayoutConstraint constraintWithItem: self.adView
attribute: NSLayoutAttributeWidth
relatedBy: NSLayoutRelationEqual
toItem: nil
attribute: NSLayoutAttributeNotAnAttribute
multiplier: 1.0
constant: kMRECWidth]]];

[self.view addConstraints: @[
[NSLayoutConstraint constraintWithItem: self.callbackTableView
attribute: NSLayoutAttributeTop
relatedBy: NSLayoutRelationEqual
toItem: self.view
attribute: NSLayoutAttributeTop
multiplier: 1.0
constant: 0],
[NSLayoutConstraint constraintWithItem: self.callbackTableView
attribute: NSLayoutAttributeLeading
relatedBy: NSLayoutRelationEqual
toItem: self.view
attribute: NSLayoutAttributeLeading
multiplier: 1.0
constant: 0],
[NSLayoutConstraint constraintWithItem: self.callbackTableView
attribute: NSLayoutAttributeTrailing
relatedBy: NSLayoutRelationEqual
toItem: self.view
attribute: NSLayoutAttributeTrailing
multiplier: 1.0
constant: 0],
[NSLayoutConstraint constraintWithItem: self.adView
attribute: NSLayoutAttributeCenterX
relatedBy: NSLayoutRelationEqual
toItem: self.view
attribute: NSLayoutAttributeCenterX
multiplier: 1.0
constant: 0.0],
[NSLayoutConstraint constraintWithItem: self.adView
attribute: NSLayoutAttributeTop
relatedBy: NSLayoutRelationEqual
toItem: self.callbackTableView
attribute: NSLayoutAttributeBottom
multiplier: 1.0
constant: 10.0],
[NSLayoutConstraint constraintWithItem: self.view
attribute: NSLayoutAttributeBottom
relatedBy: NSLayoutRelationEqual
toItem: self.adView
attribute: NSLayoutAttributeBottom
multiplier: 1.0
constant: 10],
[NSLayoutConstraint constraintWithItem: self.adView
attribute: NSLayoutAttributeHeight
relatedBy: NSLayoutRelationEqual
toItem: nil
attribute: NSLayoutAttributeNotAnAttribute
multiplier: 1.0
constant: kMRECHeight],
[NSLayoutConstraint constraintWithItem: self.adView
attribute: NSLayoutAttributeWidth
relatedBy: NSLayoutRelationEqual
toItem: nil
attribute: NSLayoutAttributeNotAnAttribute
multiplier: 1.0
constant: kMRECWidth]]];
}

- (void)viewDidDisappear:(BOOL)animated
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
NS_ASSUME_NONNULL_BEGIN

@interface ALBaseAdViewController : UIViewController

@property (nonatomic, weak) IBOutlet UITableView *callbackTableView;
/**
* Used for logging ad callbacks in the callback table.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#import "ALBaseAdViewController.h"

@interface ALBaseAdViewController ()<UITableViewDataSource>
@property (nonatomic, weak) IBOutlet UITableView *callbackTableView;
@property (nonatomic, strong) NSMutableArray<NSString *> *callbacks;

@end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="15702" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="5Gv-do-t8r">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="16097" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="5Gv-do-t8r">
<device id="retina4_7" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15704"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="16087"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
Expand Down Expand Up @@ -73,43 +73,54 @@
<scene sceneID="Kjf-YA-azc">
<objects>
<viewController title="Programmatic MRECs" hidesBottomBarWhenPushed="YES" id="bDb-jO-IMe" customClass="ALDemoProgrammaticMRECViewController" sceneMemberID="viewController">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="insetGrouped" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="18" sectionFooterHeight="18" id="Ofj-82-KA3" userLabel="CallBack Table View">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="CWl-qN-X0F"/>
<viewControllerLayoutGuide type="bottom" id="orG-zc-qsv"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="tre-Kw-sNf">
<rect key="frame" x="0.0" y="0.0" width="375" height="647"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<prototypes>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="none" indentationWidth="10" reuseIdentifier="callbackCell" textLabel="suV-Fg-wNr" style="IBUITableViewCellStyleDefault" id="SMz-43-QQ6">
<rect key="frame" x="16" y="55.5" width="343" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="SMz-43-QQ6" id="8c3-0o-IOD">
<rect key="frame" x="0.0" y="0.0" width="343" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" insetsLayoutMarginsFromSafeArea="NO" text="Title" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="suV-Fg-wNr">
<rect key="frame" x="15" y="0.0" width="313" height="43.5"/>
<subviews>
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="insetGrouped" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="18" sectionFooterHeight="18" id="HOk-jN-aNH" userLabel="CallBack Table View">
<rect key="frame" x="0.0" y="0.0" width="414" height="842"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<prototypes>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="none" indentationWidth="10" reuseIdentifier="callbackCell" textLabel="XOp-uR-zkW" style="IBUITableViewCellStyleDefault" id="OOv-YA-y8O">
<rect key="frame" x="15" y="55.5" width="384" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="OOv-YA-y8O" id="e29-Ve-JVx">
<rect key="frame" x="0.0" y="0.0" width="384" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</tableViewCellContentView>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="number" keyPath="textLabel.numberOfLines">
<integer key="value" value="2"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="boolean" keyPath="textLabel.adjustsFontSizeToFitWidth" value="YES"/>
</userDefinedRuntimeAttributes>
</tableViewCell>
</prototypes>
<connections>
<outlet property="dataSource" destination="bDb-jO-IMe" id="AjR-R1-1bH"/>
</connections>
</tableView>
<subviews>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" insetsLayoutMarginsFromSafeArea="NO" text="Title" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="XOp-uR-zkW">
<rect key="frame" x="15" y="0.0" width="354" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</tableViewCellContentView>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="number" keyPath="textLabel.numberOfLines">
<integer key="value" value="2"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="boolean" keyPath="textLabel.adjustsFontSizeToFitWidth" value="YES"/>
</userDefinedRuntimeAttributes>
</tableViewCell>
</prototypes>
<connections>
<outlet property="dataSource" destination="bDb-jO-IMe" id="wLk-LE-rsx"/>
</connections>
</tableView>
</subviews>
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
</view>
<toolbarItems/>
<navigationItem key="navigationItem" title="Programmatic MRECs" id="Qjq-MV-Cef"/>
<nil key="simulatedBottomBarMetrics"/>
<connections>
<outlet property="callbackTableView" destination="Ofj-82-KA3" id="IQr-1N-yse"/>
<outlet property="callbackTableView" destination="HOk-jN-aNH" id="PQp-f2-cr6"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="Spa-5h-Dqk" userLabel="First Responder" sceneMemberID="firstResponder"/>
Expand All @@ -130,9 +141,6 @@
<subviews>
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="insetGrouped" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="18" sectionFooterHeight="18" translatesAutoresizingMaskIntoConstraints="NO" id="bQW-9d-rv6" userLabel="CallBack Table View">
<rect key="frame" x="0.0" y="0.0" width="375" height="367"/>
<constraints>
<constraint firstAttribute="height" constant="367" id="44R-nI-G9L"/>
</constraints>
<prototypes>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="none" indentationWidth="10" reuseIdentifier="callbackCell" textLabel="Jnm-4y-9Ld" style="IBUITableViewCellStyleDefault" id="02S-r0-Tda">
<rect key="frame" x="15" y="55.5" width="345" height="43.5"/>
Expand Down Expand Up @@ -174,18 +182,19 @@
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstItem="bQW-9d-rv6" firstAttribute="top" secondItem="INv-GO-Z1M" secondAttribute="topMargin" id="67x-za-orH"/>
<constraint firstAttribute="trailing" secondItem="bQW-9d-rv6" secondAttribute="trailing" id="8qb-D1-Tsu"/>
<constraint firstItem="bQW-9d-rv6" firstAttribute="centerX" secondItem="INv-GO-Z1M" secondAttribute="centerX" id="9Hy-9P-twS"/>
<constraint firstItem="gtT-tU-6Vk" firstAttribute="top" secondItem="bQW-9d-rv6" secondAttribute="bottom" constant="10" id="LQE-5p-QcI"/>
<constraint firstItem="bQW-9d-rv6" firstAttribute="centerX" secondItem="gtT-tU-6Vk" secondAttribute="centerX" id="PGV-N3-uBC"/>
<constraint firstItem="bQW-9d-rv6" firstAttribute="leading" secondItem="INv-GO-Z1M" secondAttribute="leadingMargin" constant="-16" id="rcm-dV-qFj"/>
<constraint firstItem="bQW-9d-rv6" firstAttribute="leading" secondItem="INv-GO-Z1M" secondAttribute="leading" id="gR7-vd-cI8"/>
<constraint firstItem="NZ4-1i-Tn9" firstAttribute="top" secondItem="gtT-tU-6Vk" secondAttribute="bottom" constant="20" id="yF2-fi-xAm"/>
</constraints>
</view>
<toolbarItems/>
<nil key="simulatedBottomBarMetrics"/>
<connections>
<outlet property="adView" destination="gtT-tU-6Vk" id="zTh-vr-BNT"/>
<outlet property="callbackTableView" destination="bQW-9d-rv6" id="12c-jO-i3z"/>
<outlet property="callbackTableView" destination="bQW-9d-rv6" id="VyC-sG-xt3"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="WRa-Uo-IQ3" userLabel="First Responder" sceneMemberID="firstResponder"/>
Expand Down
Loading

0 comments on commit 85ea9c9

Please sign in to comment.