在ViewController中,修改SecondViewController
的UITextView.text
如果它是NSString类型可以这么修改:
SVC.string = @"test";
出现两个问题:
- messageBox.text没有修改
- SVC.messageBox.text 返回(null)
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";
}