UIView.h
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
@interface UIView : UIResponder {
IBOutlet UILabel *endLabel;
IBOutlet UIButton *goButton;
IBOutlet UITextField *textBox1;
IBOutlet UITextField *textBox2;
@property(nonatomic, retain) UILabel *endLabel;
@property(nonatomic, retain) UIButton *goButton;
@property(nonatomic, retain) UITextField *textBox1;
@property(nonatomic, retain) UITextField *textBox2;
}
- (IBAction)goButtonClicked;
@end
UIView.m
#import "UIView.h"
@implementation UIView
@synthesize textBox1, goButton;
@synthesize textBox2, goButton;
@synthesize textBox1, endLabel;
@synthesize textBox2, endLabel;
@synthesize goButton, endLabel;
- (IBAction)goButtonClicked {
}
@end
最佳答案
对@synthesize
有点疯狂,是吗?我确实相信您的主要问题是,在@property
的结束}之后,@interface
声明需要为。
我很惊讶编译器没有抛出一个格陵兰大小的危险信号。
另外,您可能打算制作一个UIView
的自定义子类;我将使用MyView
。//MyView.m -- correct synthesize declaration
@synthesize textBox1, goButton, textBox2, endLabel;
//MyView.h -- correct interface declaration
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
@interface MyView : UIView {
IBOutlet UILabel *endLabel;
IBOutlet UITextField *textBox1;
IBOutlet UITextField *textBox2;
IBOutlet UIButton *goButton;
}
@property(nonatomic, retain) UIButton *goButton;
@property(nonatomic, retain) UILabel *endLabel;
@property(nonatomic, retain) UITextField *textBox1;
@property(nonatomic, retain) UITextField *textBox2;
@end
关于objective-c - 为什么它不能从主文件中识别头文件中的@properties?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1116690/