【发布时间】:2014-03-01 20:31:44
【问题描述】:
我有 A 类,其中包含一个带有一些按钮的 xib 和一个 UITextField 和 B 类,其中包含一个 tableView 我想将 A 类添加到表视图标题中。
我正在使用 [[[NSBundle mainBundle] loadNibName: owner:self options:nil] objectAtIndex:0]; 将 xib 从 A 类导入 B 类
我只想在 classB 中反映按钮和 textview 操作。在 ClassB 中,我确实有一些 UITextfield 委托方法,我希望在 ClassA 中定义和声明的 uitextfield 中键入一些文本时调用这些方法(xib + .h 文件中的属性定义)。
A类.h:
//properties are set from xib file ClassA.xib
@interface ClassA : UIView
@property (unsafe_unretained, nonatomic) IBOutlet UIButton *addC;
@property(strong, nonatomic) IBOutlet UITextField *nText;
@end
B类.h
#import "ClassA"
@interface ClassB : UIViewController <UITextFieldDelegate, UITableViewDataSource,...>
@property (strong, nonatomic) IBOutlet UITableView *mTableView; //property set from ClassB.xib
@property(strong, nonatomic) IBOutlet UITextField *nText_B;
@property (unsafe_unretained, nonatomic) IBOutlet UIButton *addC_B;
- (IBAction)addC:(UIButton *)sender;
@end
我不知道如何将 ClassB 按钮和文本字段链接到 ClassA
在 ClassB viewDidLoad 方法中,我试过这个:
getHeader = [[ClassA alloc]init];
_addC_B = [getHeader addC];
_nText_B = [getHeader nText];
_nText_B.delegate =self;
_nText_B.text=@"";
但它不起作用 我在这方面是 iOS 新手。 谢谢你的帮助
【问题讨论】: