Ios presentViewController: black screen after destinationView jump
There is a button in viewA. After clicking it, it will jump to another page. Using the following code, viewB will be black and nothing will be seen.
-(void)login:(id)sender{ mainViewController *mainView=[[mainViewController alloc]init]; NSLog(@"%@",__name.text); if([__name.text isEqualToString:@"ccc"]&&[__pwd.text isEqualToString:@"123"]){ [self presentViewController:mainView animated:YES completion:nil];} }
Click ViewController of ViewB, and set the Storyboard ID in identity inspector on the right side, for example, "second". Change the code to the following format:
-(void)login:(id)sender{mainViewController *mainView=[self.storyboard instantiateViewControllerWithIdentifier:@"second"];NSLog(@"%@",__name.text);if([__name.text isEqualToString:@"ccq"]&&[__pwd.text isEqualToString:@"123"] { [self presentViewController:mainView animated:YES completion:nil];}}
Then you can jump to the viewB page.