Difficult to explain for me :-)
I already have: A main UIViewController/UIView -> works A second UIViewController/UIView which I show after a button is pressed -> works, second UIViewController/UIView is shown on top of screen and has the full screensize, so I can't see the first UIViewController/UIView
Because I realized my secondView holds only some small components, I would like: to show the second UIViewController/UIView over the first as like a popoverview, So the second is sized minimal and the first is still shown in the back.
I thought I could do simply the following:
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let vc = storyboard.instantiateViewControllerWithIdentifier("Options") as! UIViewController
vc.modalPresentationStyle = .Popover <<-- Make simply Modal ?
self.presentViewController(vc, animated: true, completion: nil)
But still the second is shown on full screen. Any help ?
Update I just managed to do by combining stuff found in the internet without knowing what I exactly I am doing :-)
func showoptions(){
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let controller = storyboard.instantiateViewControllerWithIdentifier("Options") as! UIViewController
controller.modalPresentationStyle = UIModalPresentationStyle.Popover
let popoverPresentationController = controller.popoverPresentationController
// result is an optional (but should not be nil if modalPresentationStyle is popover)
if let _popoverPresentationController = popoverPresentationController {
// set the view from which to pop up
_popoverPresentationController.sourceView = self.view;
_popoverPresentationController.sourceView.sizeToFit();
// present (id iPhone it is a modal automatic full screen)
self.presentViewController(controller, animated: true, completion: nil)
}
}
The only prolem I have now is, that the size of the modal view is too small, some compontents are not fully visible.