tufanv Expert Licensed User Longtime User Nov 13, 2022 #1 Hello, It is possible to set custom size in admob. Objective c code is as follows: B4X: GADAdSize size = GADAdSizeFromCGSize(CGSizeMake(300, 50)); How can I implement this line of code during initialization of adview? An example adview init code is: B4X: adviewhaber.Initialize("adview","", Page1, sizes.Get(0)) An example by Erel to use medium rect size using obj c is : B4X: #if objc #import <GoogleMobileAds/GoogleMobileAds.h> - (NSObject*)SIZE_MEDIUM_RECTANGLE { return [NSValue valueWithBytes:&kGADAdSizeMediumRectangle objCType:@encode(GADAdSize)]; } #end if Last edited: Nov 13, 2022
Hello, It is possible to set custom size in admob. Objective c code is as follows: B4X: GADAdSize size = GADAdSizeFromCGSize(CGSizeMake(300, 50)); How can I implement this line of code during initialization of adview? An example adview init code is: B4X: adviewhaber.Initialize("adview","", Page1, sizes.Get(0)) An example by Erel to use medium rect size using obj c is : B4X: #if objc #import <GoogleMobileAds/GoogleMobileAds.h> - (NSObject*)SIZE_MEDIUM_RECTANGLE { return [NSValue valueWithBytes:&kGADAdSizeMediumRectangle objCType:@encode(GADAdSize)]; } #end if
Erel B4X founder Staff member Licensed User Longtime User Nov 14, 2022 #2 Try this: B4X: - (NSObject*)SIZE_MEDIUM_RECTANGLE { GADAdSize size = GADAdSizeFromCGSize(CGSizeMake(300, 50)); return [NSValue valueWithBytes:&size objCType:@encode(GADAdSize)]; } Upvote 0
Try this: B4X: - (NSObject*)SIZE_MEDIUM_RECTANGLE { GADAdSize size = GADAdSizeFromCGSize(CGSizeMake(300, 50)); return [NSValue valueWithBytes:&size objCType:@encode(GADAdSize)]; }
tufanv Expert Licensed User Longtime User Nov 14, 2022 #3 Erel said: Try this: B4X: - (NSObject*)SIZE_MEDIUM_RECTANGLE { GADAdSize size = GADAdSizeFromCGSize(CGSizeMake(300, 50)); return [NSValue valueWithBytes:&size objCType:@encode(GADAdSize)]; } Click to expand... Yes, code compiles Thanks! Is it somehow possible to use a size from a b4i variable instead of using hard coded size in objc code ? I need to set the size according to users screen width and height. Upvote 0
Erel said: Try this: B4X: - (NSObject*)SIZE_MEDIUM_RECTANGLE { GADAdSize size = GADAdSizeFromCGSize(CGSizeMake(300, 50)); return [NSValue valueWithBytes:&size objCType:@encode(GADAdSize)]; } Click to expand... Yes, code compiles Thanks! Is it somehow possible to use a size from a b4i variable instead of using hard coded size in objc code ? I need to set the size according to users screen width and height.
Erel B4X founder Staff member Licensed User Longtime User Nov 15, 2022 #4 B4X: Me.As(NativeObject).RunMethod("customSize::", Array(240, 60)) #if OBJC - (NSObject*)customSize:(int)width :(int)height { GADAdSize size = GADAdSizeFromCGSize(CGSizeMake(width, height)); return [NSValue valueWithBytes:&size objCType:@encode(GADAdSize)]; } Upvote 0
B4X: Me.As(NativeObject).RunMethod("customSize::", Array(240, 60)) #if OBJC - (NSObject*)customSize:(int)width :(int)height { GADAdSize size = GADAdSizeFromCGSize(CGSizeMake(width, height)); return [NSValue valueWithBytes:&size objCType:@encode(GADAdSize)]; }
tufanv Expert Licensed User Longtime User Nov 16, 2022 #6 Erel said: B4X: Me.As(NativeObject).RunMethod("customSize::", Array(240, 60)) #if OBJC - (NSObject*)customSize:(int)width :(int)height { GADAdSize size = GADAdSizeFromCGSize(CGSizeMake(width, height)); return [NSValue valueWithBytes:&size objCType:@encode(GADAdSize)]; } Click to expand... I just tried the code, I am getting : B4X: Method not found: customSize, target: <b4i_main: (null)> When I initialize the ad. What am i doing wrong here? B4X: adviewnoti.Initialize("adviewnoti","ca-app-pu...", pagenoti, no.RunMethod("customSize", Null)) Upvote 0
Erel said: B4X: Me.As(NativeObject).RunMethod("customSize::", Array(240, 60)) #if OBJC - (NSObject*)customSize:(int)width :(int)height { GADAdSize size = GADAdSizeFromCGSize(CGSizeMake(width, height)); return [NSValue valueWithBytes:&size objCType:@encode(GADAdSize)]; } Click to expand... I just tried the code, I am getting : B4X: Method not found: customSize, target: <b4i_main: (null)> When I initialize the ad. What am i doing wrong here? B4X: adviewnoti.Initialize("adviewnoti","ca-app-pu...", pagenoti, no.RunMethod("customSize", Null))
Erel B4X founder Staff member Licensed User Longtime User Nov 16, 2022 #7 It should be: no.RunMethod("customSize::", Array(240, 60)) Upvote 0