I try to get a viewcontroller from storyboard like this:
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
ViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"vc"];
ViewController *avc = ((UINavigationController *)(_window.rootViewController)).topViewController;
But they are not the same object:
(lldb) po vc <ViewController: 0x17eaee50>
(lldb) po avc <ViewController: 0x17e72970>
Why?
They are of the same class, but different instances. instantiateViewControllerWithIdentifier
instantiates a new view controller, as the name implies :).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.