[ios] Jump page black screen solution

Xcode's Storyboard is very convenient to use the connection jump interface, but sometimes direct connection cannot solve the required problem, and directly using the presentViewController method to jump to the VC in the Storyboard will cause a black screen.

Reason: Storyboard automatically overrides the -(void)viewDidLoad method when the class corresponding to the second view is created, and the presentViewController method is not allowed to override the -(void)viewDidLoad method.

So I deleted all the contents of the ViewController2 class automatically generated by the system.

 

Solution (1):

Use storyboard's identifier to jump:

Set the storyboard ID of the second interface to vc2

The code of the btn button in the first vc:

UIStoryboard *storboard = self.storyboard;
ViewController2 *vc2 = [storboard instantiateViewControllerWithIdentifier:@"vc2"];
[self presentViewController:vc2 animated:YES completion:nil];
or
[self.navigationController pushViewController:vc2 animated:YES];

 

Solution (2) Add views and controls in viewDidLoad of vc2

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326374810&siteId=291194637