我正在尝试从 ViewController 中的 SecondViewController 更改 UITextView.text。如果它是 SecondViewController 中的 NSString 类型,我可以这样做:
SVC.string = @"test";
问题是:
- messageBox.text 没有改变
- SVC.messageBox.text 返回(空)
ViewController.m 中的方法之一:
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";
}
如何克服这个问题?