我在一个视图上有一个条形码扫描仪,并且在用户扫描条形码后,应用程序将它们带到另一个视图(BoilerDetails),其中条形码文本字段已被预先填充。从来电视图设置UITextField的文本
据我所知,viewcontroller是空的,当它没有进入视图,我不能直接更改UITextField文本。这到目前为止给了我一个错误..我该如何解决这个问题?
BarcodeScannerViewController.m
BoilerDetailsViewController *viewCtrl = [[BoilerDetailsViewController alloc] initWithNibName:nil bundle:nil];
[viewCtrl setBarcode:strBarcode];
[self.navigationController pushViewController:viewCtrl animated:YES];
BoilerDetailsViewController.h
@interface BoilerDetailsViewController : SubViewControllerBase
@property (retain, nonatomic) NSString *barcode;
@property (retain, nonatomic) IBOutlet UITextField *barcodeField;
- (void)setBarcode:(NSString*)strBarcode;
@end
BoilerDetailsViewController.m
-(void)setBarcode:(NSString *)strBarcode
{
self.barcode = strBarcode;
}
- (void)viewDidLoad
{
[super viewDidLoad];
[_barcodeField setText:self.barcode];
// Do any additional setup after loading the view from its nib.
}
在'-setBarcode:'方法内添加'self.barcodeField.text = strBarcode' – 2013-02-19 14:51:52