別のView Controllerにデータを渡すことができないため、少し問題があります。
-(void)barcodeData:(NSString *)barcode type:(int)type
{
mainTabBarController.selectedViewController=self;
[status setString:@""];
[status appendFormat:@"Type: %d\n",type];
[status appendFormat:@"Type text: %@\n",[dtdev barcodeType2Text:type]];
[status appendFormat:@"Barcode: %@",barcode];
[displayText setText:status];
codede1String = barcode;
NSLog(@"%@",codede1String);
[self updateBattery];
}
上記のコードでは、 String にバーコードを入れていcodeString1
ます。これまでのところ問題はありませんが、このデータを他のviewControllerに送信すると、barCodeStringが突然NULLになります。
次のようにviewcontrollerにデータを渡します。
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
if ([segue.identifier isEqualToString:@"barcode"]) {
main =[ segue destinationViewController];
main.code1.text = codede1String;
}
}
では、どうすればこの問題を解決できますか?