在VC中使用未声明的标识符,但在Custom UIImageView中声明它

时间:2013-09-04 09:40:58

标签: uiviewcontroller import uiimageview identifier

我在使用未声明的标识符方面遇到了麻烦。我创建了一个自定义的UIImageView,并在其中声明了@property UILabel'answeLbl'。我已将自定义UIImageView.h文件导入到我的ViewController.h文件中,但每当我尝试使用'answerLbl'时,它都会出现错误'使用未声明的标识符'。我如何阻止这个问题,我需要在我的ViewController中使用这个'answerLbl'?

这是ViewController.h

#import <UIKit/UIKit.h>
#import "NumberPadImageView.h"



@interface ViewController : UIViewController {

NumberPadImageView *numberKeyboard;

}

然后这是自定义uiiimageview =&gt; NumberPadImageView.h

#import <UIKit/UIKit.h>

@interface NumberPadImageView : UIImageView {

UILabel *answerLbl;

UIButton *oneBtn;
UIButton *twoBtn;
UIButton *threeBtn;
UIButton *fourBtn;
UIButton *fiveBtn;
UIButton *sixBtn;
UIButton *sevenBtn;
UIButton *eightBtn;
UIButton *nineBtn;
UIButton *zeroBtn;

UIButton *backBtn;
UIButton *periodBtn;
UIButton *clearAnswerFieldBtn;

}
@property (nonatomic, strong) IBOutlet UILabel *answerLbl;

-(IBAction)buttonPressed:(UIButton *)sender;
-(IBAction)backspace:(id)sender;
-(IBAction)clearAnswerLbl:(id)sender;

1 个答案:

答案 0 :(得分:0)

@property (nonatomic, strong) NumberPadImageView *imageView;

在viewDidLoad中,

self.imageView = [[NumberPadImageView alloc]init];

访问,

self.imageView.answerLbl

并将answerLbl声明为属性,

@property (nonatomic, strong) UILabel *answerLbl;