2 つのビュー コントローラー間で NSString を移動しようとしていますが、すべての複雑な方法を検索した後、慣れたい最も簡単で簡単な方法は、受信側 VC で initWithName 関数を記述し、送信側で呼び出すことでした。 VC。正常に移動しますが、 ViewDidLoad が textViewer をロードする前に実行して、タブボタンが押された直後に表示されるようにします。送信元 VC のコードは次のとおりです。
- (void)textViewDidEndEditing:(UITextView *)textView
{
if ([textView.text isEqualToString: @""]) {
textView.text = @"*Paste the machine code in question here*";
}
SecondViewController *theVCMover = [[SecondViewController alloc] initWithName: textView.text];
[self.navigationController pushViewController:theVCMover animated:YES]; //Is this really necessary if I'm not going to segue it directly, I'm just waiting for the user to press the next tab
gotItLabel.text = @"Got it! Ready for action...";
}
受信側 VC のコードは次のとおりです。
- (id)initWithName:(NSString *)theVCMovee {
self = [super initWithNibName:@"SecondViewController" bundle:nil];
if (self) {
rawUserInput = theVCMovee;
CleanerText.text = rawUserInput;
}
return self;
}
- (void)viewDidLoad {
[super viewDidLoad];
CleanerText.text = rawUserInput;
NSLog(@"Got the other tab's text and it's %@ ", rawUserInput);
}