I am trying to present a view controller modally from another view controller that is the second view inside UINavigationController. But it keep giving error and crashing. Application tried to present modally an active controller
I dont know what does it mean. Following is the way how i am calling.
UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone" bundle:nil];
FBPreviewPostViewController *previewPostViewController = [storyBoard instantiateViewControllerWithIdentifier:@"FBPreviewPostViewController"];
previewPostViewController.delegate = self;
previewPostViewController.selectedImg = selectedImage;
[self presentViewController:previewPostViewController animated:YES completion:nil];
Thanks
The error indicates that the view controller is presented twice, which is not allowed.
I don't know much about Storyboards and your app, perhaps FBPreviewPostViewController
has been presented by storyboards. You can check whether it is in view hierarchy by checking viewController.isViewLoaded && viewController.view.window
is true or not.
BTW, you are using storyboards, why don't use segue?
Can you try following code
NSString *stbName = [[NSBundle mainBundle].infoDictionary objectForKey:@"MainStoryboard_iPhone"];
UIStoryboard *Mainstoryboard = [UIStoryboard storyboardWithName:stbName bundle:nil];
FBPreviewPostViewController *previewPostViewController = [Mainstoryboard instantiateViewControllerWithIdentifier:@"FBPreviewPostViewController"];
previewPostViewController.delegate = self;
previewPostViewController.selectedImg = selectedImage;
[self presentModalViewController:previewPostViewController animated:YES];
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.