I am integrating MoPub in my app, but ran into the following error when I should write the size on the ad banner: Invalid suffix 'x50' on integer constant

self.adView = [[[MPAdView alloc] initWithAdUnitId:@"adUnitCode" size:320x50] autorelease];

If it does't work to write the size as MoPub said, does anyone know How i can write it?

有帮助吗?

解决方案

The method signature is:

- (id)initWithAdUnitId:(NSString *)adUnitId size:(CGSize)size

so you need to supply a CGSize. That could be done with CGSizeMake(320, 50) or the constant supplied by MoPub: MOPUB_BANNER_SIZE.

Writing 320x50 looks like an invalid integer to the compiler and that is the reason for the description of the problem.


So, removing your ARC issue too, you need to import the constants

#import "MPConstants.h"

and your line will be:

self.adView = [[MPAdView alloc] initWithAdUnitId:@"adUnitCode" size:MOPUB_BANNER_SIZE];

其他提示

It is expecting a CGSize struct for the size: parameter, so try:

self.adView = [[[MPAdView alloc] initWithAdUnitId:@"adUnitCode" 
                                             size:CGSizeMake(320, 50)] autorelease];
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top