Skip to content

Commit

Permalink
Updated Swift example of DoubleClick custom rendering example to incl…
Browse files Browse the repository at this point in the history
…ude native video
  • Loading branch information
Samuel Stow committed Aug 4, 2017
1 parent 124dcfc commit 6d1ac95
Show file tree
Hide file tree
Showing 11 changed files with 547 additions and 448 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="11762" systemVersion="16C67" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" colorMatched="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="12121" systemVersion="16F73" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11757"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12089"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
Expand Down Expand Up @@ -50,9 +50,9 @@
<connections>
<outlet property="captionView" destination="Opb-BT-xiP" id="hSg-rU-Z7U"/>
<outlet property="headlineView" destination="EJ7-Y2-nrO" id="BKi-kL-8EA"/>
<outlet property="mediaPlaceholder" destination="hoj-tc-K51" id="pmf-nl-x4R"/>
<outlet property="mainPlaceholder" destination="hoj-tc-K51" id="pmf-nl-x4R"/>
</connections>
<point key="canvasLocation" x="305" y="242"/>
<point key="canvasLocation" x="13" y="27"/>
</view>
</objects>
<simulatedMetricsContainer key="defaultSimulatedMetrics">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

// Weak references to this ad's asset views.
@property(nonatomic, weak) IBOutlet UILabel *headlineView;
@property(nonatomic, weak) IBOutlet UIView *mediaPlaceholder;
@property(nonatomic, weak) IBOutlet UIView *mainPlaceholder;
@property(nonatomic, weak) IBOutlet UILabel *captionView;

/// Populates the ad view with the custom native ad object.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,29 +31,29 @@ - (void)awakeFromNib {
}

- (void)performClickOnHeadline {
[self.customNativeAd performClickOnAssetWithKey:MySimpleNativeAdViewHeadlineKey];
}

- (void)populateWithCustomNativeAd:(GADNativeCustomTemplateAd *)customNativeAd {
self.customNativeAd = customNativeAd;
// The custom click handler is an optional block which will override the normal click action
// defined by the ad. Pass nil for the click handler to let the SDK process the default click
// action.
dispatch_block_t customClickHandler = ^{
__weak typeof(self) weakSelf = self;
[self.customNativeAd setCustomClickHandler:^(NSString *assetID){
[[[UIAlertView alloc] initWithTitle:@"Custom Click"
message:@"You just clicked on the headline!"
delegate:self
delegate:weakSelf
cancelButtonTitle:@"OK"
otherButtonTitles:nil] show];
};
[self.customNativeAd performClickOnAssetWithKey:MySimpleNativeAdViewHeadlineKey
customClickHandler:customClickHandler];
}

- (void)populateWithCustomNativeAd:(GADNativeCustomTemplateAd *)customNativeAd {
self.customNativeAd = customNativeAd;
}];

// Populate the custom native ad assets.
self.headlineView.text = [customNativeAd stringForKey:MySimpleNativeAdViewHeadlineKey];
self.captionView.text = [customNativeAd stringForKey:MySimpleNativeAdViewCaptionKey];

// Remove all the media placeholder's subviews.
for (UIView *subview in self.mediaPlaceholder.subviews) {
for (UIView *subview in self.mainPlaceholder.subviews) {
[subview removeFromSuperview];
}

Expand All @@ -66,17 +66,17 @@ - (void)populateWithCustomNativeAd:(GADNativeCustomTemplateAd *)customNativeAd {
UIImage *image = [customNativeAd imageForKey:MySimpleNativeAdViewMainImageKey].image;
mainView = [[UIImageView alloc] initWithImage:image];
}
[self.mediaPlaceholder addSubview:mainView];
[self.mainPlaceholder addSubview:mainView];

// Size the media view to fill our container size.
[mainView setTranslatesAutoresizingMaskIntoConstraints:NO];
NSDictionary *viewDictionary = NSDictionaryOfVariableBindings(mainView);
[self.mediaPlaceholder
[self.mainPlaceholder
addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[mainView]|"
options:0
metrics:nil
views:viewDictionary]];
[self.mediaPlaceholder
[self.mainPlaceholder
addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[mainView]|"
options:0
metrics:nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,29 @@
objects = {

/* Begin PBXBuildFile section */
4AE4C01A1BFCCF8300655115 /* NativeAppInstallAdView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4AE4C0141BFCCF8300655115 /* NativeAppInstallAdView.xib */; };
4AE4C01B1BFCCF8300655115 /* NativeContentAdView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4AE4C0161BFCCF8300655115 /* NativeContentAdView.xib */; };
4AE4C01C1BFCCF8300655115 /* SimpleCustomNativeAdView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4AE4C0181BFCCF8300655115 /* SimpleCustomNativeAdView.xib */; };
4AEBD8B41BF01CF200874961 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4AEBD8B31BF01CF200874961 /* AppDelegate.swift */; };
4AEBD8B61BF01CF200874961 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4AEBD8B51BF01CF200874961 /* ViewController.swift */; };
4AEBD8B91BF01CF200874961 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 4AEBD8B71BF01CF200874961 /* Main.storyboard */; };
4AEBD8BB1BF01CF200874961 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 4AEBD8BA1BF01CF200874961 /* Assets.xcassets */; };
4AEBD8BE1BF01CF200874961 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 4AEBD8BC1BF01CF200874961 /* LaunchScreen.storyboard */; };
4AEBD8CC1BF01E7300874961 /* MySimpleNativeAdView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4AEBD8CB1BF01E7300874961 /* MySimpleNativeAdView.swift */; };
AEB485B61F31462D0030B852 /* SimpleCustomNativeAdView.xib in Resources */ = {isa = PBXBuildFile; fileRef = AEB485B51F31462D0030B852 /* SimpleCustomNativeAdView.xib */; };
AEB485B81F314BA90030B852 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = AEB485B71F314BA90030B852 /* Main.storyboard */; };
AEB485BB1F314D6E0030B852 /* NativeAppInstallAdView.xib in Resources */ = {isa = PBXBuildFile; fileRef = AEB485B91F314D6E0030B852 /* NativeAppInstallAdView.xib */; };
AEB485BC1F314D6E0030B852 /* NativeContentAdView.xib in Resources */ = {isa = PBXBuildFile; fileRef = AEB485BA1F314D6E0030B852 /* NativeContentAdView.xib */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
4AE4C0151BFCCF8300655115 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/NativeAppInstallAdView.xib; sourceTree = "<group>"; };
4AE4C0171BFCCF8300655115 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/NativeContentAdView.xib; sourceTree = "<group>"; };
4AE4C0191BFCCF8300655115 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/SimpleCustomNativeAdView.xib; sourceTree = "<group>"; };
4AEBD8B01BF01CF200874961 /* DFPCustomRenderingExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = DFPCustomRenderingExample.app; sourceTree = BUILT_PRODUCTS_DIR; };
4AEBD8B31BF01CF200874961 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
4AEBD8B51BF01CF200874961 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
4AEBD8B81BF01CF200874961 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
4AEBD8BA1BF01CF200874961 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
4AEBD8BD1BF01CF200874961 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
4AEBD8BF1BF01CF200874961 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
4AEBD8CB1BF01E7300874961 /* MySimpleNativeAdView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MySimpleNativeAdView.swift; sourceTree = "<group>"; };
AEB485B51F31462D0030B852 /* SimpleCustomNativeAdView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = SimpleCustomNativeAdView.xib; path = Base.lproj/SimpleCustomNativeAdView.xib; sourceTree = "<group>"; };
AEB485B71F314BA90030B852 /* Main.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = Main.storyboard; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
AEB485B91F314D6E0030B852 /* NativeAppInstallAdView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = NativeAppInstallAdView.xib; path = Base.lproj/NativeAppInstallAdView.xib; sourceTree = "<group>"; };
AEB485BA1F314D6E0030B852 /* NativeContentAdView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = NativeContentAdView.xib; path = Base.lproj/NativeContentAdView.xib; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -65,11 +65,11 @@
4AEBD8B31BF01CF200874961 /* AppDelegate.swift */,
4AEBD8B51BF01CF200874961 /* ViewController.swift */,
4AEBD8CB1BF01E7300874961 /* MySimpleNativeAdView.swift */,
4AEBD8B71BF01CF200874961 /* Main.storyboard */,
AEB485B71F314BA90030B852 /* Main.storyboard */,
4AEBD8BC1BF01CF200874961 /* LaunchScreen.storyboard */,
4AE4C0141BFCCF8300655115 /* NativeAppInstallAdView.xib */,
4AE4C0161BFCCF8300655115 /* NativeContentAdView.xib */,
4AE4C0181BFCCF8300655115 /* SimpleCustomNativeAdView.xib */,
AEB485B91F314D6E0030B852 /* NativeAppInstallAdView.xib */,
AEB485BA1F314D6E0030B852 /* NativeContentAdView.xib */,
AEB485B51F31462D0030B852 /* SimpleCustomNativeAdView.xib */,
4AEBD8BA1BF01CF200874961 /* Assets.xcassets */,
4AEBD8BF1BF01CF200874961 /* Info.plist */,
);
Expand Down Expand Up @@ -136,11 +136,11 @@
buildActionMask = 2147483647;
files = (
4AEBD8BE1BF01CF200874961 /* LaunchScreen.storyboard in Resources */,
4AE4C01C1BFCCF8300655115 /* SimpleCustomNativeAdView.xib in Resources */,
AEB485B61F31462D0030B852 /* SimpleCustomNativeAdView.xib in Resources */,
4AEBD8BB1BF01CF200874961 /* Assets.xcassets in Resources */,
4AE4C01B1BFCCF8300655115 /* NativeContentAdView.xib in Resources */,
4AE4C01A1BFCCF8300655115 /* NativeAppInstallAdView.xib in Resources */,
4AEBD8B91BF01CF200874961 /* Main.storyboard in Resources */,
AEB485BB1F314D6E0030B852 /* NativeAppInstallAdView.xib in Resources */,
AEB485BC1F314D6E0030B852 /* NativeContentAdView.xib in Resources */,
AEB485B81F314BA90030B852 /* Main.storyboard in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -160,38 +160,6 @@
/* End PBXSourcesBuildPhase section */

/* Begin PBXVariantGroup section */
4AE4C0141BFCCF8300655115 /* NativeAppInstallAdView.xib */ = {
isa = PBXVariantGroup;
children = (
4AE4C0151BFCCF8300655115 /* Base */,
);
name = NativeAppInstallAdView.xib;
sourceTree = "<group>";
};
4AE4C0161BFCCF8300655115 /* NativeContentAdView.xib */ = {
isa = PBXVariantGroup;
children = (
4AE4C0171BFCCF8300655115 /* Base */,
);
name = NativeContentAdView.xib;
sourceTree = "<group>";
};
4AE4C0181BFCCF8300655115 /* SimpleCustomNativeAdView.xib */ = {
isa = PBXVariantGroup;
children = (
4AE4C0191BFCCF8300655115 /* Base */,
);
name = SimpleCustomNativeAdView.xib;
sourceTree = "<group>";
};
4AEBD8B71BF01CF200874961 /* Main.storyboard */ = {
isa = PBXVariantGroup;
children = (
4AEBD8B81BF01CF200874961 /* Base */,
);
name = Main.storyboard;
sourceTree = "<group>";
};
4AEBD8BC1BF01CF200874961 /* LaunchScreen.storyboard */ = {
isa = PBXVariantGroup;
children = (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
{
"images" : [
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "29x29",
Expand Down Expand Up @@ -30,6 +40,16 @@
"size" : "60x60",
"scale" : "3x"
},
{
"idiom" : "ipad",
"size" : "20x20",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "20x20",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "29x29",
Expand Down
Loading

0 comments on commit 6d1ac95

Please sign in to comment.