我是故事板的新手。任何想法为什么会发生这种情况?当我从包含视图控制器中的按钮触发“测试”时,日志显示 vc1(如预期的那样)但是当我从另一个视图控制器“触发”test2 时,我得到 null ..
@property (readonly, strong, nonatomic) UIViewController *vc1;
- (IBAction)test:(id)sender {
NSLog(@"log %@", _vc1 );
}
- (void)test2 {
NSLog(@"log %@", _vc1 );
}
- (void)viewDidLoad
{
[super viewDidLoad];
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
_vc1 = [storyboard instantiateViewControllerWithIdentifier:@"test1"];
}