我一直在尝试将 iAD 实现到我的一个视图控制器中,并且在为 .h 和 .m 文件编写代码之后......我收到了这个语义问题错误:
@synthesize of 'weak' property is only allowed in ARC or GC mode
我特别在 .m 文件的 @implementation 旁边得到了这个错误。任何关于我如何解决这个问题的建议都非常感谢。
我还想知道是否可以将这个广告横幅(一旦工作)从这个视图控制器复制并粘贴到其他视图控制器上而不需要重新编码?
这是我在 .h 文件中的 iAD 代码
#import <UIKit/UIKit.h>
#import <iAd/iAd.h>
@interface ViewController : UIViewController <ADBannerViewDelegate>
@property (weak, nonatomic) IBOutlet ADBannerView *banner;
@end
这是我在 .m 文件中的 iAD 代码
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
self.banner.delegate = self;
}
- (void) viewDidLayoutSubviews {
if (self.banner.bannerLoaded) {
CGRect contentFrame = self.view.bounds;
CGRect bannerFrame = self.banner.frame;
contentFrame.size.height -= self.banner.frame.size.height;
bannerFrame.origin.y = contentFrame.size.height;
self.banner.frame = bannerFrame;
}
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (BOOL)bannerViewActionShouldBegin:(ADBannerView *)banner willLeaveApplication: (BOOL)willLeave
{
NSLog(@"bannerViewActionShouldBegin");
return YES;
}
- (void)bannerViewDidLoadAd:(ADBannerView *)banner
{
NSLog(@"bannerViewDidLoadAd");
}
- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error
{
NSLog(@"didFailToReceiveAdWithError");
}
- (void)bannerViewActionDidFinish:(ADBannerView *)banner {
NSLog(@"bannerViewActionDidFinish");
}
@end