-3

我对此很陌生,所以请原谅我很容易修复错误

。H

#import <UIKit/UIKit.h>
#import <iAd/iAd.h>
@interface withadViewController : UIViewController <ADBannerViewDelegate>{

ADBannerView *banner;
BOOL bannerIsVisible;

IBOutlet UITextField *textField1;
IBOutlet UITextField *textField2;
IBOutlet UILabel *label1;
}
@property (nonatomic, assign)BOOL bannerIsVisible;
@property (nonatomic, retain)IBOutlet ADBannerView *banner;
-(IBAction)calculate;
-(IBAction)clear;
@end

.m(所有问题的原因不明)

#import "withadViewController.h"
@interface withadViewController ()                  HERE IT SAYS INCOMPLETE IMPLEMENTATION
@end
@implementation withadViewController
@synthesize banner;
@synthesize bannerIsVisible;
-(void) bannerViewDidLoadAd:(ADBannerView *)banner {
if (!self.bannerIsVisible) {
    [UIView beginAnimations:@"animatedAdBannerOn" context:NULL];
    banner.frame = CGRectOffset(banner.frame, 0.0, 50.0); HERE SAYS LOCAL DECLARATION OF BANNER HIDES INSTANCE VARIABLE
    [UIView commitAnimations];
    self.bannerIsVisible = YES;
    }
}
-(void)bannerView:(ADBannerView *)aBanner didFailToReceiveAdWithError:(NSError *)error {
if (!self.bannerIsVisible) {
    [UIView beginAnimations:@"animatedAdBannerOff" context:NULL];
    banner.frame = CGRectOffset(banner.frame, 0.0, -320.0);
    [UIView commitAnimations];
    self.bannerIsVisible = NO;
}

 -(IBAction)calculate {                           HERE IT SAYS EXPECTED EXPRESSION

int x = ([textField1.text floatValue]);
int c = x*([textField2.text floatValue]);

label1.text = [[NSString alloc]initWithFormat:@"%2d", c];
}
-(IBAction)clear {
textField1.text = @"";
textField2.text = @"";
label1.text = @"";{
}
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}

- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}  
@end                                                             HERE IT SAYS MISSING @END

这是所有 .h 和 .m 文件

4

2 回答 2

1

你永远不会关闭你的方法:

-(void)bannerView:(ADBannerView *)aBanner didFailToReceiveAdWithError:(NSError *)error

这导致编译器看不到您已实现的方法(不完整的实现)不理解@end并期望表达式。

您的局部变量正在隐藏您的实例变量,因为它们都被命名为banner. 类似于以下代码如何隐藏外部变量:

id var;
{
    id var;
}

您可以通过将参数重命名为aBanner.

于 2013-08-29T20:04:52.603 回答
1

你没有关闭你的 if 语句:

- (void)bannerView:(ADBannerView *)aBanner didFailToReceiveAdWithError:(NSError *)error {
    if (!self.bannerIsVisible) {
        [UIView beginAnimations:@"animatedAdBannerOff" context:NULL];
        banner.frame = CGRectOffset(banner.frame, 0.0, -320.0);
        [UIView commitAnimations];
        self.bannerIsVisible = NO;
    } // <-- HERE
}

我怀疑周围还有其他类似的错误。再过一遍,一步一步来。

缩进代码并保持整洁对于避免此类问题大有帮助。:)

于 2013-08-29T20:05:29.447 回答