I'm trying to integrate AdMob into an app on iOS 7 and I can not seem to get the banner to show. I have read the other questions pertaining to this issue and they don't seem to have any good information. Here is the code I'm using:
AdMob = [[GADBannerView alloc] initWithFrame:CGRectMake(0, self.view.frame.size.height - GAD_SIZE_320x50.height, GAD_SIZE_320x50.width, GAD_SIZE_320x50.height)];
//AdMob.frame = CGRectMake(0, self.view.frame.size.height - GAD_SIZE_320x50.height, GAD_SIZE_320x50.width, GAD_SIZE_320x50.height);
AdMob.adUnitID = #"MYAPPID";
AdMob.rootViewController = self;
AdMob.delegate = self;
[self.view addSubview:AdMob];
GADRequest *r = [[GADRequest alloc] init];
r.testDevices = [NSArray arrayWithObjects:#"MYDEVICEID", nil];
r.testing = YES;
[AdMob loadRequest:r];
I've tested on simulator and on device with no luck.
Related
I am using Flurry in my iOS app, to display banner ads as follows:
self.flurryBanner = [[FlurryAdBanner alloc] initWithSpace:#"FlurryBanner"];
self.flurryBanner.adDelegate = self;
[self.flurryBanner fetchAdForFrame:self.view.frame];
while I can find documentation in AdMob to hide banner (setHidden = YES), I could not find any information on how to do so. Any ideas for a good practice?
You can do it like this
UIView *flurryContainer = [[UIView alloc] initWithFrame:CGRectMake(0, 150, self.view.frame.size.width, 50)];
[self.view addSubview:flurryContainer];
[self.flurryBanner displayAdInView:flurryContainer viewControllerForPresentation:self];
And then flurryContainer.hidden = YES;
I use Google Ad Mob for ios app.
It works when I run app in test device. But if I download from store, The app can not show the banner (empty banner view)
I also turn on the ios advertising settings.
Could anyone get this error before?
Thanks
CGRect screenRect = [[UIScreen mainScreen] bounds];
CGFloat screenHeigth = screenRect.size.height;
bannerView_ = [[GADBannerView alloc] initWithAdSize:kGADAdSizeBanner origin:CGPointMake(0, screenHeigth-kGADAdSizeBanner.size.height)];;
bannerView_.adUnitID = #"ca-app-pub-../..";
bannerView_.rootViewController = self;
[self.view addSubview:bannerView_];
GADRequest *request = [GADRequest request];
request.testDevices = #[
#".." ];
[bannerView_ loadRequest:request];
You need to comment out/remove:
request.testDevices = #[#".." ];
And add:
bannerView_.delegate = self;
Make sure your Ad Unit ID is exactly the same as what AdMob has supplied you with.
bannerView_.adUnitID = #"ca-app-pub-../..";
I am creating an app using Phonegap and Onsen UI. I am able to show the Admob ads using this code:
- (void)webViewDidFinishLoad:(UIWebView*)theWebView
{
// Black base color for background matches the native apps
theWebView.backgroundColor = [UIColor blackColor];
CGPoint origin = CGPointMake(0.0,
self.view.frame.size.height -
CGSizeFromGADAdSize(kGADAdSizeBanner).height);
bannerView_ = [[GADBannerView alloc] initWithAdSize:kGADAdSizeBanner
origin:origin];
bannerView_.center = CGPointMake(self.view.center.x, self.view.frame.size.height-CGSizeFromGADAdSize(kGADAdSizeBanner).height/2);
bannerView_.adUnitID = #"myid";
bannerView_.rootViewController = self;
[self.view addSubview:bannerView_];
[bannerView_ loadRequest:[GADRequest request]];
return [super webViewDidFinishLoad:theWebView];
}
However, if I use iframe, the ads will not showing. Why this happened and how to solve it?
i have added all the required files and frameworks for integrating admob. The problem is that it does not add the subview to the viewcontroller.
My viewcontroller consist of a navigation bar and a UITableView. What i want to achieve is to have a admob in the button of my viewcontroller. How can i achieve this.
At the moment i'm using following code, which is not doing anything and not giving me any errors:
bannerView_.adUnitID = #"Banner Key";
bannerView_.rootViewController = self;
[self.view addSubview:bannerView_];
[bannerView_ loadRequest:[GADRequest request]];
Perhaps you need to set the frame of the banner as well?
1 must set the frame of ad banner so that it can be displayed:
m_bannerView = [[GADBannerView alloc] initWithAdSize:kGADAdSizeBanner];
m_bannerView.adUnitID = #"AD Unit ID";
m_bannerView.rootViewController = self;
m_bannerView.delegate = self;
m_bannerView.frame = CGRectMake(0, 64, 320, 50); // 64 = height of navigation bar
GADRequest *request = [GADRequest request];
[self.view addSubview:m_bannerView];
[m_bannerView loadRequest:request];
You can set the origin points of the adBanner like below.
self.adBanner = [[GADBannerView alloc]initWithAdSize:kGADAdSizeBanner
origin:CGPointMake(0,31)];
self.adBanner.adUnitID = #"YOUR_KEY";
self.adBanner.delegate = self;
self.adBanner.rootViewController = self;
[self.view addSubview:self.adBanner];
[self.adBanner loadRequest:[self request]];
I want to use an UIImagePickerController non-modally, with a small square preview. However, I get a big black bar at the bottom of the preview, which I can't get rid of (see the screenshot). Why is it there, and how can I get rid of it?
Code:
- (void)viewDidLoad
{
[super viewDidLoad];
_imagePickerVC = [[UIImagePickerController alloc] init];
_imagePickerVC.sourceType = UIImagePickerControllerSourceTypeCamera;
_imagePickerVC.mediaTypes = #[ (NSString *)kUTTypeImage ];
_imagePickerVC.wantsFullScreenLayout = NO;
_imagePickerVC.delegate = (id)self;
_imagePickerVC.navigationBarHidden = YES;
_imagePickerVC.allowsEditing = NO;
_imagePickerVC.showsCameraControls = NO;
_imagePickerVC.cameraDevice = UIImagePickerControllerCameraDeviceFront;
CGRect previewFrame = CGRectMake(0, 0, 150, 150);
[_imagePickerVC.view setFrame:previewFrame];
_imagePickerVC.view.autoresizesSubviews = YES;
[self.view addSubview:_imagePickerVC.view];
[_imagePickerVC viewWillAppear:YES];
[_imagePickerVC viewDidAppear:YES];
}
This is a misuse of UIImagePickerController. To make your own image-capture interface, simply use AVFoundation.