ViewController の SecondViewController から UITextView.text を変更しようとしています。SecondViewController の NSString タイプであれば、次のようにして実行できます。
SVC.string = @"test";
問題はそれです:
- messageBox.text は変更されません
- SVC.messageBox.text が返されます (null)
ViewController.m のメソッドの 1 つ:
SecondViewController *SVC = [[SecondViewController alloc]initWithNibName:@"SecondViewController" bundle:nil];
SVC.messageBox.text = @"changed";
NSLog(@"SVC: %@", SVC.messageBox.text); // result = (null)
[self presentViewController:SVC animated:YES completion:NULL];
SecondViewController.h:
#import <UIKit/UIKit.h>
@interface SecondViewController : UIViewController
@property (nonatomic) IBOutlet UITextView *messageBox;
@end
SecondViewController.m:
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
self.messageBox.text = @"first";
}
これをどうやって乗り越えますか?